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


Groups > gnu.bash.bug > #14229

Re: Case of set -e not being in effect in a subshell.

From Clark Wang <dearvoid@gmail.com>
Newsgroups gnu.bash.bug
Subject Re: Case of set -e not being in effect in a subshell.
Date 2018-06-11 23:06 +0800
Message-ID <mailman.1664.1528729607.1292.bug-bash@gnu.org> (permalink)
References <CAG2j0scsLBhh8b5aB_ORYS+ND0jUWzfnGsE9u3WO4TGHdhc4WQ@mail.gmail.com>

Show all headers | View raw


On Mon, Jun 11, 2018 at 6:12 PM, Bartłomiej Palmowski <rotwang@crux.org.pl>
wrote:

>
> The issue is:
> $ cat bad
> (
>     set -e
>     false
>     echo "Shouldn't happen?"
> ) && :
> $ bash ./bad ; echo $?
> Shouldn't happen?
> 0
> $ cat good
> (
>     set -e
>     false
>     echo "Shouldn't happen?"
> )
> $ bash ./good ; echo $?
> 1
>
> Probably there is something obvious that I'm missing.
>

According to bash man page:

> The shell does not exit if the command that fails is [...] part of any
command executed in a && or || list except the command following the final
&& or ||, [...]

-clark

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


Thread

Re: Case of set -e not being in effect in a subshell. Clark Wang <dearvoid@gmail.com> - 2018-06-11 23:06 +0800

csiph-web