RedditEnjoyer@lemmy.world to Linux@lemmy.ml · 5 months agoA Linux user's nightmare: the machine was wiped clean with one clickwww.mikrobitti.fiexternal-linkmessage-square50fedilinkarrow-up1119arrow-down115file-text
arrow-up1104arrow-down1external-linkA Linux user's nightmare: the machine was wiped clean with one clickwww.mikrobitti.fiRedditEnjoyer@lemmy.world to Linux@lemmy.ml · 5 months agomessage-square50fedilinkfile-text
minus-squareUnityDevice@startrek.websitelinkfedilinkarrow-up27·5 months agoset -euo pipefail at the top of every script makes stuff a lot safer. Explanation here.
minus-squaredeadbeef79000@lemmy.nzlinkfedilinkarrow-up8·5 months agoYep! I always do this too. TL;DR: e aborts the whole script on a non-zero error. u aborts when using an undefined variable. -o pipefail aborts a piped compound command when one of the piped commands fail. Any other way lies madness. Or erasing the whole filesystem apparently!
set -euo pipefail
at the top of every script makes stuff a lot safer. Explanation here.Yep! I always do this too.
TL;DR:
e
aborts the whole script on a non-zero error.u
aborts when using an undefined variable.-o pipefail
aborts a piped compound command when one of the piped commands fail.Any other way lies madness. Or erasing the whole filesystem apparently!