3 ms·
`set -e` is basically a way to find where you need better error-handling, not a way to make scripts safe. I'd much rather a crummy script run into trouble calli
by falsedan 8y ago
`set -e` is basically a way to find where you need better error-handling, not a way to make scripts safe. I'd much rather a crummy script run into trouble calling some new featuref, shrug, and move on to the core business-critical code, instead of erroring out and triggering a bunch of pages.
- ianbicking 8y agoDo you normally protect every command with || exit? cd foobar || exit It's those really small failures that cause shell scripts to do crazy things without set -e.
- falsedan 8y agoWhy wouldn't I rewrite the script to avoid the cd instead? The point of `set -e` isn't to insert all those pointless guards, it's to point out "hey this might fail, so think of a way to do this that doesn't rely on cd". For your extremely thin example, if it (say) removed some files, I would only remove the files from the current directory or an absolute path.