bug-bash
[Top][All Lists]
Advanced

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

Re: set -e works incorrectly in subshells


From: Roman Rakus
Subject: Re: set -e works incorrectly in subshells
Date: Wed, 23 Nov 2011 12:55:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0

On 11/23/2011 11:26 AM, Марк Коренберг wrote:
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include
-I../bash/lib   -g -O2 -Wall
uname output: Linux mmarkk-work 2.6.38-12-generic #51-Ubuntu SMP Wed
Sep 28 14:27:32 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.2
Patch Level: 8
Release Status: release

Repeat-By:
        mmarkk@mmarkk-work:~$ ( set -e; echo aaa; false; echo bbb )
        aaa
        mmarkk@mmarkk-work:~$ ( set -e; echo aaa; false; echo bbb ) || true
        aaa
        bbb
        mmarkk@mmarkk-work:~$
Expect:
        mmarkk@mmarkk-work:~$ ( set -e; echo aaa; false; echo bbb )
        aaa
        mmarkk@mmarkk-work:~$ ( set -e; echo aaa; false; echo bbb ) || true
        aaa
        mmarkk@mmarkk-work:~$mmarkk@mmarkk-work:~$

Not a bug.
See man page of set builtin; quoting:
 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  following  the  if or elif reserved
words, part of any command executed in a && or  ||  list
except  the  command  following  the final && or ||, any
command in a pipeline but the last, or if the  command's
return  value  is being inverted with !.





reply via email to

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