Re: `jobs` within command substitution doesn't work

Christoph Anton Mitterer <[email protected]> Wed, 23 Oct 2024 21:11:17 +0200
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
Hey.

From https://pubs.opengroup.org/onlinepubs/9799919799/utilities/jobs.html :

> DESCRIPTION
>
> If the current shell execution environment (see 2.13 Shell
> Execution Environment ) is not a subshell environment, the jobs
> utility shall display the status of background jobs that were created
> in the current shell execution environment; it may also do so if the
> current shell execution environment is a subshell environment.

So I guess dash is indeed allowed to behave as it does.


OTOH:

> APPLICATION USAGE
>
...
> The -p option is the only portable way to find out the process
> group of a job-control background job because different
> implementations have different strategies for defining the process
> group of the job. Usage such as $(jobs -p) provides a way of
> referring to the process group of the job in an
> implementation-independent way.

Which kinda implies (though in the informative-only section, of
course), that there's indeed some intended need for $(jobs -p).

So, could dash be made to behave the other way?


btw: While playing around, I've noticed that:
$ foo="$(sleep 60 &)"
cannot be <Ctrl-C>ed in dash (which works in e.g. bash.).


Cheers,
Chris.