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

Re: Option PRINT_EXIT_VALUE doesn't always work as expected



On Fri, 30 Jul 2010 15:02:04 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:
> Also, if tst is a script that does "exit 141", I get as expected:
> 
> ypig% ./tst | head -n 1
> zsh: exit 141   ./tst | 
> zsh: done       head -n 1
> ypig% echo $pipestatus
> 141 0
> 
> but if tst does "kill -PIPE $$", I get:
> 
> ypig% ./tst | head -n 1
> ypig% echo $pipestatus
> 141 0

The fact that the signal number + 128 is added to get the status isn't
currently taken account at that point.  It should presumably be
transparent.

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.76
diff -p -u -r1.76 jobs.c
--- Src/jobs.c	31 Jul 2010 21:06:12 -0000	1.76
+++ Src/jobs.c	31 Jul 2010 21:47:54 -0000
@@ -873,6 +873,10 @@ printjob(Job jn, int lng, int synch)
 		    sflag = 1;
 		if (job == thisjob && sig == SIGINT)
 		    doputnl = 1;
+		if (isset(PRINTEXITVALUE) && isset(SHINSTDIN)) {
+		    sflag = 1;
+		    skip_print = 0;
+		}
 	    } else if (WIFSTOPPED(pn->status)) {
 		sig = WSTOPSIG(pn->status);
 		if ((int)strlen(sigmsg(sig)) > len)


-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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