Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11337

Re: -e does not take effects in subshell

From Eric Blake <eblake@redhat.com>
Newsgroups gnu.bash.bug
Subject Re: -e does not take effects in subshell
Date 2015-08-12 23:09 -0600
Organization Red Hat, Inc.
Message-ID <mailman.8234.1439442606.904.bug-bash@gnu.org> (permalink)
References <BLU176-W28809FB59FF9274B34D871D67F0@phx.gbl> <20150811135056.GD4309@eeg.ccf.org> <BLU176-W27103575D91F4EF315336FD67D0@phx.gbl>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 08/12/2015 09:54 PM, PRC wrote:
> 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?

Like it or not, it is the historical behavior standardized by POSIX. It
is NOT intuitive, and our advice is "DON'T USE set -e - IT WON'T DO WHAT
YOU WANT".  We can't change the behavior, because it would break scripts
that rely on the POSIX-specified behavior.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: -e does not take effects in subshell Eric Blake <eblake@redhat.com> - 2015-08-12 23:09 -0600

csiph-web