bug-bash
[Top][All Lists]
Advanced

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

Re: set -e is not clearly documented


From: Chet Ramey
Subject: Re: set -e is not clearly documented
Date: Mon, 07 Oct 2013 10:21:06 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0

On 10/7/13 5:01 AM, Bartłomiej Palmowski wrote:
> Hi,
> 
> lets consider the following:
> 
> $ echo $BASH_VERSION
> 4.1.2(1)-release
> $ cat /etc/system-release
> Red Hat Enterprise Linux Server release 6.3 (Santiago)
> $ ( set -e; echo foo; false; echo bar; ) # this one is expected
> foo
> $ ( set -e; echo foo; false; echo bar; ) || true # this one is not expected
> foo
> bar
> 
> documentation (http://www.gnu.org/software/bash/manual/bash.html) states
> that:
> 
> [...] The shell does not exit if the command that fails is part of the
> command list immediately following a while or until keyword, part of the
> test in an if statement, part of any command executed in a && or || [...]
> 
> In this case it is not clear since set -e is invoked inside subshell and ||
> is outside this subshell.

The subshell command is clearly part of the || compound command.  The
subshell `knows' that it is part of || and set -e has no effect.  This
example has been discussed before, on this list and the austin-group
Posix list, and the bash behavior is correct.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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