From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id 60A2D23042 for ; Sat, 20 Jan 2024 00:23:17 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1705706597; b=LYivbKzTfHZbHEdFSW1yunAChEl1lO0V67wj7u/hnLUJ64Q7MH0y30s/mlV3aXQDV3vB98oCUV cVXJ+Ju0oKdZR8lZXTS9j8suxGTaiUcEgLWwzKtIOZd7P7Rk+6+DubxN7YtQZXaxEtIDfGPTNa 354o7Mssh62qitWQjbtJyIZBcStHDNu9+ZU6ZyLhgso8QuB+8q2QT1TOW2R48Jg1VRPoyhfO5D uV7mdsGswdHe6l/EXFCdvS9g6bXyqxklFyfsqjWomvsFUfLdY+HCo3XIyoG1MbV3T4EcpqjrsX iquCqoDncZPsC+X92X5312FrcqjPTi8yhzYPwXyg7h2zKw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (lxh-heta-035.node.capitar.com) smtp.remote-ip=159.69.139.61; dmarc=none header.from=opperschaap.net; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1705706597; bh=Au9oY4DDwo8zCNicUqzp37bSJcyWk7d588Xw1eL2vEE=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:To:From:DKIM-Signature; b=PkgjV/Limv9EnDec14AVFpUUd5oaxTNFm9iXFqxEYdKKRjLFih/xgcKaALjLjDVhKzNovtPefv Q4xClgJCdm8r1bLD2lLZ1uB+q1ghiI/q5q8T/aq77DfsuW4XeyBoVao3SSR7fGW/u1F2FEslP9 l4aogwQrz7+9ctkBHoV9nMNk5ux4HSXtzVNDZQBh5ivhiRPmxtvozqCKE3cFfiWdtLg9qlcSiz aiEWhGUHG718IqQp188DcjYS5aEqRprzjSggfVtx/yQ2a/rtdezbkd2ZP3cJFY7Q3Dnuv2e0uB L7FofuLZNIWp00mhj0x+mt0Ckyyl2T19b3GriH71MEOzug==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=AOcY7xRUChc/PFmhuIt6kNG2L3lYlw8dRb9C33M/5Ew=; b=e4vEcfa5P4bUC7PegYogV8ME5X lrwirqqHajhzWBE7Zq/7RjgWovZggl/9ErGESreKDpSIOpXJaWcIoc1Pp1URzS2MOvucLUcj5RpM/ Xr6TOISn2lLCb1maZS0SgqSZSX2nR3Chxm7mTceXa2c0jJnvVd4yIQInlE60V/oz72F3SNqX0tIJq 3lnFQPywUhfTB8G2sXeKZZoIEQmXAhO4bum/2sCZHNVBCM0LgB5Gvcn7ny0BFFO4ox23gA73s+ro4 x0VnLyLq0QgKRc7McjXTdiRPkz3fCkBwdqgK+/DvT/tL3OPDa5WReoXaOLjMOr152fWGBLakv9Ode doTkw0UQ==; Received: by zero.zsh.org with local id 1rQyCi-000P8D-ID; Fri, 19 Jan 2024 23:23:16 +0000 Authentication-Results: zsh.org; iprev=pass (lxh-heta-035.node.capitar.com) smtp.remote-ip=159.69.139.61; dmarc=none header.from=opperschaap.net; arc=none Received: from lxh-heta-035.node.capitar.com ([159.69.139.61]:44814 helo=eur-mail-proxy-p01.zt.capitar.com) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rQyC9-000Oo1-6E; Fri, 19 Jan 2024 23:22:43 +0000 Received: from eur-mail-proxy-p01.zt.capitar.com (localhost [127.0.0.1]) by eur-mail-proxy-p01.zt.capitar.com (Postfix) with ESMTPS id 5D28E48CBB; Sat, 20 Jan 2024 00:22:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by eur-mail-proxy-p01.zt.capitar.com (Postfix) with ESMTP id D5A6A48C3A; Sat, 20 Jan 2024 00:22:39 +0100 (CET) Received: from eur-mail-proxy-p01.zt.capitar.com ([127.0.0.1]) by localhost (eur-mail-proxy-p01.zt.capitar.com [127.0.0.1]) (amavis, port 10026) with ESMTP id bMy4w6YSwhKL; Sat, 20 Jan 2024 00:22:39 +0100 (CET) Received: from sputnik-odin.setarnet.aw (186-189-151-106.setardsl.aw [186.189.151.106]) by eur-mail-proxy-p01.zt.capitar.com (Postfix) with ESMTPSA id 02B9548F0F; Sat, 20 Jan 2024 00:22:37 +0100 (CET) From: Wesley Schwengle To: zsh-workers@zsh.org Subject: [PATCH] Fix jobs -p to be POSIX compliant Date: Fri, 19 Jan 2024 19:22:29 -0400 Message-ID: <20240119232229.177255-1-wesleys@opperschaap.net> X-Mailer: git-send-email 2.42.0.1140.gf01f4dc781 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=Vp9d/N+n c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=NNsMJ0FP/O/2rce1Ysg3eA==:17 a=dEuoMetlWLkA:10 a=xNf9USuDAAAA:8 a=N3miCFJ7AAAA:8 a=Sr38FOTTjcVmhA5wb5gA:9 a=SEwjQc04WA-l_NiBhQ7s:22 a=V5H4rQgsk92nlYCD-KPC:22 X-Seq: 52489 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: In Debian the following bug was reported: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=3D346162 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 --- 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 =3D jn->procs; pn;) { + if (lng & 2) { + pid_t x =3D jn->gleader; + fprintf(fout, "%ld", (long) x); + putc('\n', fout); + doneprint =3D 1; + break; + } len2 =3D (thisfmt ? 5 : 10) + len; /* 2 spaces */ if (lng & 3) qn =3D 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 =3D jn->gleader; - - fprintf(fout, "%ld ", (long) x); - do - skip++; - while ((x /=3D 10)); - skip++; - lng &=3D ~3; - } else + else fprintf(fout, "%*s", skip, ""); if (pn->status =3D=3D 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* =20 zpty_start --=20 2.42.0.1140.gf01f4dc781