#1065411 dash: 'jobs' utility does not generate output in a pipe

Package:
dash
Source:
dash
Description:
POSIX-compliant shell
Submitter:
Marc Lehmann
Date:
2024-03-04 05:27:03 UTC
Severity:
normal
#1065411#5
Date:
2024-03-04 05:09:50 UTC
From:
To:
Dear Maintainer,

I found that 'jobs' in dash is silent when stdout is a pipe:

   # dash -c 'sleep 1&sleep 1&jobs|wc -l'
   0

afaics, this is not documented behaviour, and other utilities (kill, alias) seem
to work fine.

bash does allow the output of jobs to be parsed:

   # bash -c 'sleep 1&sleep 1&jobs|wc -l'
   2

I think the bash behaviour is more useful for shell programming, and
probably correct, as the sus does not seem to indicate that jobs should
have no output in this case.