On 2021/03/23 05:57, David T-G wrote:
Again, I disagree. This is probably a religious^Wphilosophical difference, but IMHO it is better to fail upon a failure, even if that means that your login is interrupted and you have to fix it, than to quietly mask the failure. The trivial
---- Uh...If you can't login and you are logging in remotely, you are saying it is better for you to have to abort your vacation in ....wherever... I think that might be defined as self-masochism. Always better for system to come up usable and send off an email to root if it is that serious (assuming root is forwarded to you).
unset TARGETDIR # something failed; this is empty cd $TARGETDIR rm -rf *
--- Why would you put something like that in a script? vs: #/bin/bash -u cd "$TARGETDIR" || { status=$? printf >&2 "ERROR: Failed cd into %s: %d\n" "$TARGETDIR" $? exit 1; } rm -rf "$TARGETDIR" ---- The above is multiply protected and would fail if it saw TARGETDIR used and unset. If I want to see the error message instead of a canned bash message, I'd use: cd "${TARGET:-}" or cd "${TARGET?Target cannot be empty} Most of my system seem like 50-75% error checking, so there's no way a script should be so bad.
is one obvious example. There are many other less-obvious ways to screw up almost as badly.