bug-bash
[Top][All Lists]
Advanced

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

RE: -e does not take effects in subshell


From: PRC
Subject: RE: -e does not take effects in subshell
Date: Thu, 13 Aug 2015 03:54:18 +0000

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: wooledg@eeg.ccf.org
> To: ijkxyz@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

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