3 ms·
These are generally good tips. I swear by set -e # same as set -o errexit and I like using list constructs (&& ||) in lieu of simple `if` test blocks but
by Adaptive 15y ago
These are generally good tips. I swear by
set -e # same as set -o errexit
and I like using list constructs (&& ||) in lieu of simple `if` test blocks but it's really important to remember that list constructs aren't exactly the same. This always catches me out:
if [ -e "missingfile" ]
then
echo "you'll never see this"
fi
(above runs fine with set -e)
[ -e "missingfile" ] && echo "you'll never see this"
(while that one correctly fails and thus `set -e` fails the script)
I generally stick an `|| true` on the end of those list constructs.
fwiw.