[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Case of set -e not being in effect in a subshell.
From: |
Clark Wang |
Subject: |
Re: Case of set -e not being in effect in a subshell. |
Date: |
Mon, 11 Jun 2018 23:06:02 +0800 |
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