4 ms·
"Errors should never pass silently." is more relevant for `set -e`
by d0mine 10y ago
"Errors should never pass silently." is more relevant for `set -e`
- ymse 10y agoExcept they do even with `set -e`. Especially if you forget to/can't set `pipefail` (which is bash-specific). Or consider the last example from the wiki link above: set -e f() { local var=$(somecommand that fails); } f # will not exit
- lisivka 10y agoYep, it is inconsistent: $ ( set -e; foo() { f=$(false); }; foo ; ); echo $? 1 $ ( set -e; foo() { local f=$(false); }; foo ; ); echo $? 0 $ ( set -e; foo() { local f; f=$(false); }; foo ; ); echo $? 1 However, it is still better to use -e to catch errors early.