[Top][All Lists]

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

Re: -e does not take effects in subshell

From: Eric Blake
Subject: Re: -e does not take effects in subshell
Date: Wed, 12 Aug 2015 23:09:59 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0

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

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

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