Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: non-interactive set -m



Peter Stephenson <p.w.stephenson <at> ntlworld.com> writes:

> 
> Peter Stephenson wrote:
> > (The other chunk is because we allow "jobs" to work in a subshell
> > so you can pipe its output---if you "set -m" you're effectively making
> > the shell the output for "jobs" twice.)
>            ^
> 
> The missing word is "save".  When you do "set -m" in the subshell you're
> wiping the record of the parent shell's job control---that's inevitable
> if you now want the subshell to do its own job control.
> 

POSIX says the following about sh:

A shell execution environment consists of the following:
...
Options turned on at invocation or by set
...
Process IDs of the last commands in asynchronous lists known to this shell
environment;
...
A subshell environment shall be created as a duplicate of the shell environment,
except that signal traps set by that shell environment shall be set to the
default values. 


It also says, for wait:

If it is called in a subshell or separate utility execution environment, such as
one of the following:
(wait)
...
it returns immediately because there are no known process IDs to wait for in
those environments.


I interpret this to mean that subshells of a parent process with job control on
must also have job control on, but that their list of tracked processes is nuked.

So we are getting closer, but still not there.

$ zsh -ci 'echo $-; (echo $-)'

should have identical output on both lines (the subshell should not lose the
fact that -m was set in the parent shell).

Likewise, I argue that this should follow bash's behavior, and not print
anything between 'got' and 'here' since there are no jobs known to the subshell:

$ zsh -ci 'sleep 1& (echo got; jobs; echo here)'

-- 
Eric Blake




Messages sorted by: Reverse Date, Date, Thread, Author