bug-bash
[Top][All Lists]
Advanced

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

Re: command substitution is stripping set -e from options


From: Christoph Gysin
Subject: Re: command substitution is stripping set -e from options
Date: Fri, 2 Oct 2015 15:53:42 +0300

> Since it's a function, I would recommend return instead of exit.  Also,
> you don't need the $? there.  exit (or return) with no arguments will
> retain the exit status of the previous command.

Yes, $? is not needed.

exit or return is equivalent in this case though because of set -e.

> Putting "|| return" or "|| exit" after all critical commands in your
> script is precisely what you should do.  (Some people write a die()
> function and then use "|| die 'my message'" instead.)

I consider all commands critical, and if one is allowed to return
unsuccessful, I'd rather explicitly allow it with something like:

can_fail || :

I'm still curious as to why set -e is stripped in the first place?

Chris
-- 
echo mailto: NOSPAM !#$.'<*>'|sed 's. ..'|tr "<*> !#:2" org@fr33z3



reply via email to

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