Hey Chet, Thanks for the quick reply. I have some follow-up questions:
- Is there an elegant way I can start an external process without it showing up under jobs, even on affected versions? My current best idea is: (_="$(/bin/echo)"; jobs -l) - Is there an elegant way I can get the correct number of jobs, even on affected versions? My current best idea is to run jobs once before doing the count: (jobs &> /dev/null; jobs | wc -l) I'm trying to keep the behaviour consistent across all versions of Bash. Thanks, Ajeet On Wed, Jun 14, 2023 at 8:17 PM Chet Ramey <chet.ra...@case.edu> wrote: > On 6/14/23 4:47 AM, Ajeet D'Souza wrote: > > > Bash Version: 5.2 > > Patch Level: 15 > > Release Status: release > > > > *Description:* > > I apologize if this is not a bug, but I couldn't find any documentation > > around this behaviour. > > > > In Bash, this does not produce any output: > > /bin/echo; jobs -l > > > > But if you run it in a subshell, it does: > > (/bin/echo; jobs -l) # output: [1] 42135 Done > /bin/echo > > > > Similar problem if you put this into $PROMPT_COMMAND, although it does > not > > run in a subshell AFAIK: > > PROMPT_COMMAND='/bin/echo; jobs -l' # output on every prompt: [1] 42135 > > Done /bin/echo > > > > This happens only for external processes, if you were to use the builtin > > echo, it would not show any background process. > > Thanks for the report. I changed this back in late September, 2022 after > a bug-bash discussion: > > https://lists.gnu.org/archive/html/bug-bash/2022-09/msg00067.html > > The original report was > > https://lists.gnu.org/archive/html/bug-bash/2022-07/msg00117.html > > The original (through bash-5.2) behavior was due to the subshell not > notifying the user about the status of the completed foreground job, > even though not running it in a subshell ignored foreground jobs. The > fix was to remove terminated foreground jobs the shell would never notify > the user about (foreground jobs not killed by a signal) from the jobs list. > > 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/ > >