`jobs` within command substitution doesn't work

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

With dash 0.5.12-9 from Debian unstable, it seem jobs doesn't work
within command substitution.

In bash:
$ sleep 60 &
[1] 140013
$ jobs -p
140013
$ echo $(jobs -p)
140013
$ 


but in dash:
$ sleep 60 &
$ jobs -p
140049
$ echo $(jobs -p)

$ 


Not really sure whether that’s behaviour which POSIX would allow, but
at least it makes it more or less impossible to easily get the PIDs of
and jobs within scripts.


Cheers,
Chris.