Repository navigation
Conversation
Setting `set -e` to stop on first error. This is good bash practice...
|
Hi @mmattel, thanks for the PR and for the kind words! I tested
In So I'd rather not add a global
If you'd like to rework the PR in that direction, I'm happy to review it. |
ekalinin
left a comment
There was a problem hiding this comment.
Requesting changes, since the problems from my comment above are still there on current master. A global set -e breaks two cases that work today:
- Stdin input with an unreadable
token.txt. WithoutGH_TOC_TOKEN,printf '# Hello\n## World\n' | ./gh-md-toc -prints an empty line and exits 0. Withoutset -eit falls back to an unauthenticated request and prints the TOC. - No network error message in POSIX mode. With
sh gh-md-toc README.md(bash in POSIX mode, e.g. on macOS), a failingcurlstops the script inside the command substitution, before the check from #172 runs. You get no message and exit 7 instead of "Parsing local markdown file requires access to github API" and exit 1. With--skip-headerit also leaves aREADME.md~~file behind.
The errors set -e was meant to catch are handled separately now: #151 adds the API error checks for stdin input, and #179 tracks the other error-handling bugs. If you'd like to rework this PR into targeted fixes, I'm happy to review it.
Setting
set -eto stop on first error. This is good bash practice...BTW, I like this script a lot !!