Open adrelanos opened 9 years ago
Yep, I need to make a cleanup.
If a sigspec is ERR, the command arg is executed whenever a simple command has a non-zero exit status, subject to the following conditions. The ERR trap is not executed if the failed command is part of the command list immediately following an until or while keyword, part of the test following the if or elif reserved words, part of a command executed in a && or || list, or if the command’s return status is being inverted using !. These are the same conditions obeyed by the errexit option.
Will plan to do this
Few more notes: Consider use of this
set -o pipefail
set -o errtrace
set -o nounset
set -o errexit
Interesting! I found "nounset" to be unproductive. But I will be curious to see your conclusion!
"trap ERR"'s are my preferred way over "errexit". Combining those seems counterproductive to me leading to confusing results. Except, sometimes I find it useful to temporarily set "errexit" before setup of the real "trap ERR" has been done.
(Related: "enable errtrace" (#60))
Due to trap ERR, I think currently a few
[ $? -ne 0 ]
checks will be never used.https://github.com/martincmelik/Securix-Linux/blob/master/securix-install/install.sh#L404
https://github.com/martincmelik/Securix-Linux/blob/master/securix-install/install.sh#L419
https://github.com/martincmelik/Securix-Linux/blob/master/securix-install/install.sh#L861
https://github.com/martincmelik/Securix-Linux/blob/master/securix-install/install.sh#L789
https://github.com/martincmelik/Securix-Linux/blob/master/securix-install/install.sh#L797
https://github.com/martincmelik/Securix-Linux/blob/master/securix-install/install.sh#L813
https://github.com/martincmelik/Securix-Linux/blob/master/securix-install/chroot.sh#L130
There might be a few others. In other scripts? Just search for
$?
.Personally I am using something like this.
But how to fix this is a stylistic question.