4 ms·
The " || exit 1" is unnecessary. Just use "set -e" at the top of the script once.
by e40 16y ago
The " || exit 1" is unnecessary. Just use "set -e" at the top of the script once.
- gruseom 16y agoLooking for more about this, I found a pretty good post: http://www.davidpashley.com/articles/writing-robust-shell-scripts.html http://www.davidpashley.com/articles/writing-robust-shell-sc...
- Nick_C 16y agoJust be aware that using 'set -e', while good advice in general, won't catch everything. Particularly lists and sub-shells may return with the status code of the last command, not the failed command, depending on how they were used. So it is possible a command failed within but won't trigger the -e. The best way is to write the compound commands and any sub-shell commands so that they will exit with the return status of any command that failed, using, say, &&.