3 ms·
If you're writing scripts, use that and don't forget -e and -u -e Exit immediately if a pipeline (which may consist of a single simple command), a list
by deskr 2y ago
If you're writing scripts, use that and don't forget -e and -u
-e Exit immediately if a pipeline (which may consist of a single simple command), a list, or a compound command (see SHELL GRAMMAR above), exits with a non-zero status
-u Treat unset variables and parameters other than the special parameters "@" and "*" as an error when performing parameter expansion
- deleted 2y ago[deleted]
- ykonstant 2y agoFor `set -u` I mostly agree. For `set -e` see my comment below and Greg's wiki: http://mywiki.wooledge.org/BashFAQ/105 http://mywiki.wooledge.org/BashFAQ/105
- deskr 2y ago> and they still fail to catch even some remarkably simple cases I totally agree. Although I'd say that there isn't anything "remarkably simple" about writing a bash script. Anything in the shell scripting world that seems remarkably simple is just because one hasn't realised the ghosts and horrors that lurk in the shadows. But I'll use -e anytime. It feels like having a protective proton pack at least.