1.  If the function is complicated and contains lots of commands, it 
would be more troublesome appending && to every command rather 
than simply using one single "set -e" at the front.
2.  It is not 
reasonable that suppression of '-e' is applied as well inside the 
function. My intention is if my_build succeeds continue to do other 
stuff. Does anyone like the rule that a function never fails only if it is part 
of a 
compound command?

> Date: Tue, 11 Aug 2015 09:50:56 -0400
> From: wool...@eeg.ccf.org
> To: ijk...@msn.com
> CC: bug-bash@gnu.org
> Subject: Re: -e does not take effects in subshell
> 
> On Tue, Aug 11, 2015 at 11:42:29AM +0000, PRC wrote:
> > mybuild()
> > {
> >     (
> >         set -e
> >         make
> >         echo "build okay"
> >     )
> > }
> > 
> > mybuild && do_other_stuff
> 
> http://mywiki.wooledge.org/BashFAQ/105
> 
> Since mybuild is invoked as part of a compound command, set -e is
> suppressed.  I guess this applies not only to set -e that's invoked
> beforehand, but even to set -e that's set within the compound command.
> 
> Stop using set -e and all of these problems simply go away.
> 
> mybuild() {
>     make && echo "build okay"
> }
> 
> mybuild && do_other_stuff
                                          

Reply via email to