Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH v2] Fix jobs -p to be POSIX compliant



On Sat, Jan 20, 2024 at 4:31 AM Wesley Schwengle
<wesleys@xxxxxxxxxxxxxxx> wrote:
>
> POSIX says that with "jobs -p", only the PID is output, whereas zsh
> outputs full information.
>
> There is discussion in the bug regarding POSIX_BUILTINS and refers to
> workers/21366. The latter is interesting because it refers to setopt
> long_list_jobs. I would want to argue that jobs -p should only show the
> PID regardless of that setting and POSIX_BUILTINS. jobs has the -l
> option, where the full line is displayed. From that point it doesn't
> make a whole lot of sense to have jobs -p do the same thing.

This is not correct.  As you noted later, "jobs -p" lists information
about process group leaders only, whereas "jobs -l" lists all jobs.
This differs mainly when there's a pipeline:

% sleep 30 | sleep 20 | sleep 10 &
[1] 67157 67158 67159
% jobs -p
[1]  + 67157 running    sleep 30 |
             running    sleep 20 | sleep 10
% jobs -l
[1]  + 67157 running    sleep 30 |
       67158 running    sleep 20 |
       67159 running    sleep 10
%

> Than there is the issue where its argued that zsh shows the group pid
> and not the actual pid of the process that is running. I looked at the
> output of bash and with this patch zsh and bash act similar.

More relevant is how they compare without the patch.

If we really wanted to make this POSIX compliant, we should arrange
that "jobs -lp" shows "more information" only about process group
leaders (currently -l simply overrides -p) and add "jobs -n" to
produce the notifications that are suppressed by "setopt no_notify"
(setopt long_list_jobs would apply here).

However, I'm generally not in favor of changing longstanding zsh
behavior for POSIX compliance without some kind of additional
conditions, such as [[ -o POSIX_JOBS ]] in this case.




Messages sorted by: Reverse Date, Date, Thread, Author