On 10/1/15 6:24 AM, Christoph Gysin wrote:
> It seems that set -e is stripped from the options ($-) when executing
> commands with command substitution:
> 
> $ bash -euc 'echo $-; f(){ false; echo $->&2; }; x=$(f)'
> ehuBc
> huBc
> 
> I would expect the shell to exit as soon as it executes 'false'.
> 
> Is this intended? Is it documented somewhere?

Yes, it's how bash has always behaved, at least back to bash-1.14 when
I stopped looking.  Around bash-2.05, it changed to preserve the -e
option when in Posix mode.

That exception from default bash behavior is documented in the Posix
Mode section of the texinfo manual.

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

Reply via email to