[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

errexit/set -e again (was: bash 'let' can give error)

From: Marc Herbert
Subject: errexit/set -e again (was: bash 'let' can give error)
Date: Fri, 10 Dec 2010 17:13:33 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv: Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Thunderbird/3.1.6

Le 10/12/2010 16:19, Dominic Raferd a écrit :
> Thanks Greg (and also Eric and Andreas). Your FAQ makes it very clear; 
> that is to say, it makes it clear how darned complicated it is. Seems 
> best to avoid using 'set -e' altogether, as you say (except perhaps at 
> an early stage for debugging): point taken.

I use set -e almost systematically in non-trivial code and I am very
happy with it. Except in extremely rare cases, when I accidentally
forget to append "|| true" after... let. This is still far less annoying than
having scripts that keep running after a failure. Or having to append "|| die"
after each command.

If you are really too afraid to use it in production it can still
prove useful like this:

if $DEBUG_MODE; then
  set -e

Following a number of discussions on this list, I feel like the majority of
highly respected experts here who regularly warn against set -e have
never seriously tried to use it on a large scale.

Le 10/12/2010 15:54, Eric Blake a écrit :
> Remember, non-zero status is NOT always 'failure'; it is the
> documentation of each command that will tell you which status values
> imply failure.

I do not find this to be a problem in practice: except for "let" the
exit status is very intuitive for practically every command.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]