From: Wesley Schwengle <wesleys@opperschaap.net>
To: zsh-workers@zsh.org
Subject: [PATCH] Fix jobs -p to be POSIX compliant
Date: Fri, 19 Jan 2024 19:22:29 -0400 [thread overview]
Message-ID: <20240119232229.177255-1-wesleys@opperschaap.net> (raw)
In Debian the following bug was reported:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=346162
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.
These patch makes the jobs -p POSIX compliant
Signed-off-by: Wesley Schwengle <wesleys@opperschaap.net>
---
Src/jobs.c | 18 ++++++++----------
Test/W02jobs.ztst | 2 +-
2 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/Src/jobs.c b/Src/jobs.c
index 118c5e61b..50f4fa3cf 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1209,6 +1209,13 @@ printjob(Job jn, int lng, int synch)
putc('\n', fout);
}
for (pn = jn->procs; pn;) {
+ if (lng & 2) {
+ pid_t x = jn->gleader;
+ fprintf(fout, "%ld", (long) x);
+ putc('\n', fout);
+ doneprint = 1;
+ break;
+ }
len2 = (thisfmt ? 5 : 10) + len; /* 2 spaces */
if (lng & 3)
qn = pn->next;
@@ -1235,16 +1242,7 @@ printjob(Job jn, int lng, int synch)
fprintf(fout, "zsh: ");
if (lng & 1)
fprintf(fout, "%ld ", (long) pn->pid);
- else if (lng & 2) {
- pid_t x = jn->gleader;
-
- fprintf(fout, "%ld ", (long) x);
- do
- skip++;
- while ((x /= 10));
- skip++;
- lng &= ~3;
- } else
+ else
fprintf(fout, "%*s", skip, "");
if (pn->status == SP_RUNNING) {
if (!conted)
diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst
index d52888dd9..11bbdbf43 100644
--- a/Test/W02jobs.ztst
+++ b/Test/W02jobs.ztst
@@ -128,7 +128,7 @@
0:`jobs -l` and `jobs -p` with running job
*>\[1] [0-9]##
*>\[1] + [0-9]## running*sleep*
-*>\[1] + [0-9]## running*sleep*
+*>[0-9]##
*>zsh:*SIGHUPed*
zpty_start
--
2.42.0.1140.gf01f4dc781
next reply other threads:[~2024-01-19 23:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-19 23:22 Wesley Schwengle [this message]
2024-01-20 12:30 ` [PATCH v2] " Wesley Schwengle
2024-01-20 21:14 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240119232229.177255-1-wesleys@opperschaap.net \
--to=wesleys@opperschaap.net \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).