Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11571
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: command substitution is stripping set -e from options |
| Date | 2015-10-01 16:19 -0400 |
| Message-ID | <mailman.217.1443730755.16064.bug-bash@gnu.org> (permalink) |
| References | <CADex794C1jOf0wrB298_O4ohAqZghYUdd9DJcuaOvV1dCP5AOQ@mail.gmail.com> |
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 chet@case.edu http://cnswww.cns.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: command substitution is stripping set -e from options Chet Ramey <chet.ramey@case.edu> - 2015-10-01 16:19 -0400
csiph-web