On 7/17/22 11:52 PM, Koichi Murase wrote:
Bash Version: 5.1.4, also in the current devel 87a6e89e
Description:
In interactive shells, the foreground dead jobs (i.e., foreground
jobs that have already terminated) in trap handlers, commands called
through `bind -x', and `PROMPT_COMMAND' (let us call these three
contexts as the affected context. Note: There might be even other
similar contexts) are treated as if they are the background dead
jobs. This causes several unintended behaviors: (1) When `jobs' is
called in the affected contexts, all the foreground jobs that have
already terminated in the same call of the affected contexts are
printed. (2) When `wait -n' is called in the affected contexts, it
immediately returns with the exit status of the previous foreground
dead job.
These behaviors are different from those in the normal case where
`jobs' and `wait -n' are executed outside the trap handler, and I do
not see the reasoning for this behavior difference between inside
and outside of the affected contexts. I hope the behavior in the
affected contexts would be similar to that in the normal contexts
where the foreground dead job information is not printed.
Thanks for the detailed report and suggested patches. I applied a variant
of your patch 3; the change to print_job appears not to be needed (at least
all of your test cases work without it).
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/