3 ms·
Do 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
by ianbicking 8y ago
Do 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.