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

Re: `jobs -p` does not behave as documented and required by POSIX



On Wed, Dec 20, 2017 at 09:45:49AM +0000, Peter Stephenson wrote:
> On Wed, 20 Dec 2017 08:56:20 +0100
> Matthias Richerzhagen <matthias.richerzhagen@xxxxxxxxxxxxxxxxxxx> wrote:
> > Hello,
> >
> > the manpage for the `jobs` buildin function states:
> >
> > >       −p        Display only the process IDs for the process group
> > >       leaders of the selected jobs.
> >
> > > STDOUT
> > >        If the −p option is specified, the output shall consist of one
> > > line for each process ID:
> > >
> > >            "%d\n", <process ID>
>
> Erm, I don't think you're looking at the right manual...

The text Matthias is quoting is from the POSIX specification
(http://pubs.opengroup.org/onlinepubs/009695399/utilities/jobs.html). I
think their point is moot though because Z-shell does not claim to be
POSIX compliant in its default mode. That said, when running Z-shell as
"sh", the output of `jobs -p` still includes the "extra" information:

    ~$ (exec -a sh zsh -c 'sleep 1 & sleep 2 & jobs -p')
    [1]  - 1022 running    sleep 1
    [2]  + 1023 running    sleep 2

Eric



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