Sun Nov 6 20:58:00 2022 UTC ()
zsh: add candidate upstream patch for bg/fg issue with shell functions

Bump PKGREVISION.


(wiz)
diff -r1.104 -r1.105 pkgsrc/shells/zsh/Makefile
diff -r1.78 -r1.79 pkgsrc/shells/zsh/distinfo
diff -r0 -r1.1 pkgsrc/shells/zsh/patches/patch-Src_jobs.c

cvs diff -r1.104 -r1.105 pkgsrc/shells/zsh/Makefile (expand / switch to unified diff)

--- pkgsrc/shells/zsh/Makefile 2022/07/01 23:31:49 1.104
+++ pkgsrc/shells/zsh/Makefile 2022/11/06 20:58:00 1.105
@@ -1,17 +1,17 @@ @@ -1,17 +1,17 @@
1# $NetBSD: Makefile,v 1.104 2022/07/01 23:31:49 rin Exp $ 1# $NetBSD: Makefile,v 1.105 2022/11/06 20:58:00 wiz Exp $
2 2
3DISTNAME= zsh-5.9 3DISTNAME= zsh-5.9
4PKGREVISION= 1 4PKGREVISION= 2
5CATEGORIES= shells 5CATEGORIES= shells
6MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=zsh/} 6MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=zsh/}
7EXTRACT_SUFX= .tar.xz 7EXTRACT_SUFX= .tar.xz
8 8
9MAINTAINER= pkgsrc-users@NetBSD.org 9MAINTAINER= pkgsrc-users@NetBSD.org
10HOMEPAGE= https://zsh.sourceforge.io/ 10HOMEPAGE= https://zsh.sourceforge.io/
11COMMENT= The Z shell 11COMMENT= The Z shell
12LICENSE= gnu-gpl-v2 AND zsh 12LICENSE= gnu-gpl-v2 AND zsh
13 13
14USE_LANGUAGES= c c99 14USE_LANGUAGES= c c99
15USE_TOOLS+= makeinfo 15USE_TOOLS+= makeinfo
16GNU_CONFIGURE= yes 16GNU_CONFIGURE= yes
17INFO_FILES= yes 17INFO_FILES= yes

cvs diff -r1.78 -r1.79 pkgsrc/shells/zsh/distinfo (expand / switch to unified diff)

--- pkgsrc/shells/zsh/distinfo 2022/07/01 23:31:49 1.78
+++ pkgsrc/shells/zsh/distinfo 2022/11/06 20:58:00 1.79
@@ -1,9 +1,10 @@ @@ -1,9 +1,10 @@
1$NetBSD: distinfo,v 1.78 2022/07/01 23:31:49 rin Exp $ 1$NetBSD: distinfo,v 1.79 2022/11/06 20:58:00 wiz Exp $
2 2
3BLAKE2s (zsh-5.9.tar.xz) = 1ab2ab9dd0debc176bdefd661b62e102153c26f591e35916ccc7527c337d0530 3BLAKE2s (zsh-5.9.tar.xz) = 1ab2ab9dd0debc176bdefd661b62e102153c26f591e35916ccc7527c337d0530
4SHA512 (zsh-5.9.tar.xz) = d9138b7f379ad942a5f46819d2dd52d31f3a1129f2a0d1b53d4c5cd43c318b60396da6d37c57c477b8e958fb750209aca0ae93f8c9dd42ac958de006a0ff067e 4SHA512 (zsh-5.9.tar.xz) = d9138b7f379ad942a5f46819d2dd52d31f3a1129f2a0d1b53d4c5cd43c318b60396da6d37c57c477b8e958fb750209aca0ae93f8c9dd42ac958de006a0ff067e
5Size (zsh-5.9.tar.xz) = 3332400 bytes 5Size (zsh-5.9.tar.xz) = 3332400 bytes
6SHA1 (patch-Completion_BSD_Command___bsd__pkg) = fe0d9cc399fe185ce71a64431e4086ed07920cb8 6SHA1 (patch-Completion_BSD_Command___bsd__pkg) = fe0d9cc399fe185ce71a64431e4086ed07920cb8
7SHA1 (patch-Completion_Unix_Command___gpg) = 8eba031838b1cfb0bfadf0fa539e760fd1cb539c 7SHA1 (patch-Completion_Unix_Command___gpg) = 8eba031838b1cfb0bfadf0fa539e760fd1cb539c
8SHA1 (patch-Config_installfns.sh) = ef0b250a0121c0e4925022e02553aefa23e6cc8d 8SHA1 (patch-Config_installfns.sh) = ef0b250a0121c0e4925022e02553aefa23e6cc8d
 9SHA1 (patch-Src_jobs.c) = d4be7424283f22a5ce26ba6aebfe51f105c033ce
9SHA1 (patch-configure) = 1b757f0ba6611a206f2e9c4d3de5c11fc629a364 10SHA1 (patch-configure) = 1b757f0ba6611a206f2e9c4d3de5c11fc629a364

File Added: pkgsrc/shells/zsh/patches/patch-Src_jobs.c
$NetBSD: patch-Src_jobs.c,v 1.1 2022/11/06 20:58:00 wiz Exp $

Candidate fix for shell function pipeline bg/fg issue, from
https://zsh.org/mla/workers/2022/msg01204.html

--- Src/jobs.c.orig	2022-05-08 06:18:22.000000000 +0000
+++ Src/jobs.c
@@ -544,16 +544,14 @@ update_job(Job jn)
 
     if (isset(MONITOR)) {
 	pid_t pgrp = gettygrp();           /* get process group of tty      */
+	int deadpgrp = (mypgrp != pgrp && inforeground && pgrp > 1 &&
+			kill(-pgrp, 0) == -1 && errno == ESRCH);
 
 	/* is this job in the foreground of an interactive shell? */
 	if (mypgrp != pgrp && inforeground &&
-	    (jn->gleader == pgrp ||
-	     (pgrp > 1 &&
-	      (kill(-pgrp, 0) == -1 && errno == ESRCH)))) {
+	    ((jn->gleader == pgrp && signalled) || deadpgrp)) {
 	    if (list_pipe) {
-		if (somestopped || (pgrp > 1 &&
-				    kill(-pgrp, 0) == -1 &&
-				    errno == ESRCH)) {
+		if (somestopped || deadpgrp) {
 		    attachtty(mypgrp);
 		    /* check window size and adjust if necessary */
 		    adjustwinsize(0);
@@ -566,6 +564,12 @@ update_job(Job jn)
 		     * when the job is finally deleted.
 		     */
 		    jn->stat |= STAT_ATTACH;
+		    /*
+		     * If we're in shell jobs on the right side of a pipeline
+		     * we should treat it like a job in the current shell.
+		     */
+		    if (inforeground == 2)
+			inforeground = 1;
 		}
 		/* If we have `foo|while true; (( x++ )); done', and hit
 		 * ^C, we have to stop the loop, too. */
@@ -1488,10 +1492,7 @@ addproc(pid_t pid, char *text, int aux, 
 	 * set it for that, too.
 	 */
 	if (gleader != -1) {
-	    if (jobtab[thisjob].stat & STAT_CURSH)
-		jobtab[thisjob].gleader = gleader;
-	    else
-		jobtab[thisjob].gleader = pid;
+	    jobtab[thisjob].gleader = gleader;
 	    if (list_pipe_job_used != -1)
 		jobtab[list_pipe_job_used].gleader = gleader;
 	    /*
@@ -1500,7 +1501,7 @@ addproc(pid_t pid, char *text, int aux, 
 	     */
 	    last_attached_pgrp = gleader;
 	} else if (!jobtab[thisjob].gleader)
-		jobtab[thisjob].gleader = pid;
+	    jobtab[thisjob].gleader = pid;
 	/* attach this process to end of process list of current job */
 	pnlist = &jobtab[thisjob].procs;
     }
@@ -2488,6 +2489,7 @@ bin_fg(char *name, char **argv, Options 
 		jobtab[job].stat &= ~STAT_CURSH;
 	    }
 	    if ((stopped = (jobtab[job].stat & STAT_STOPPED))) {
+		/* WIFCONTINUED will makerunning() again at killjb() */
 		makerunning(jobtab + job);
 		if (func == BIN_BG) {
 		    /* Set $! to indicate this was backgrounded */