Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15599
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: set -e ignored in subshell if part of command list |
| Date | 2019-11-15 07:57 -0500 |
| Message-ID | <mailman.1557.1573822678.13325.bug-bash@gnu.org> (permalink) |
| References | (1 earlier) <13040a55-507d-e072-e827-be7c33be968f@case.edu> <CAMhR0U3yqJ5N-gMCOK7SspOJcdcOCEtu_+cV3=zUgr7fJmkRRQ@mail.gmail.com> <d3c4201b-85d4-eb53-fbd7-ef389f6f7f03@case.edu> <1573772541.924.11.camel@debian.16bits.net> <e36f54b8-a3cd-fa84-0fb8-993c8fd49fe4@case.edu> |
On 11/14/19 6:02 PM, Ángel wrote: > On 2019-11-13 at 11:30 -0500, Chet Ramey wrote: >> On 11/13/19 10:59 AM, Shaun Crampton wrote: >>> But the commands in the subshell execute inside a different shell >>> execution context so they shouldn't have >>> their own set -e context (Section 2.12)? >> >> Why? That section says the only thing that changes in the subshell >> environment is signal dispositions. >> >> In fact, the example in the set builtin description explicitly assumes >> the subshell inherits the errexit setting. The only thing the standard >> requires here is that setting -e in the subshell doesn't change the >> parent's setting. >> >> But that's not exactly the point. The shell is "executing any command of an >> AND-OR list other than the last" so errexit is ignored. > > > I would say that the confusing part is that the behavior of the subshell > is dependant on *where* it is being executed in the parent. > > In general terms, I would expect > ( <code> ) > to be roughly equivalent to > bash -c "<code>" > > i.e. <code> being executed on its own context and unable to affect the > parent That's not a good assumption. When the shell executes a command in a subshell, it forks and executes the command. The subshell is an exact copy of its parent, so of course it depends on the parent's state at the time it's created. The subshell being unable to affect the parent's state is just a consequence of the relationship between processes. If you want to execute something in a `pristine' environment, you can use `bash -c' as you showed. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: set -e ignored in subshell if part of command list Chet Ramey <chet.ramey@case.edu> - 2019-11-15 07:57 -0500
csiph-web