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

PATCH: Re: Is PRINT_EXIT_VALUE supposed to work?



On Jun 15,  2:22pm, Peter Stephenson wrote:
} Subject: Is PRINT_EXIT_VALUE supposed to work?
}
} I've never looked at this option until now, when I'm trying to write a
} test for it.  It doesn't work with functions.

The simplest thing seems to be the patch below.  I don't see any reason
to print the exit value of a builtin before flushing the stdout of that
builtin (though I also don't know of any case where it matters that the
stdout of the builtin gets flushed).

--- zsh-forge/current/Src/exec.c	Sat Jun 23 11:24:32 2001
+++ zsh-4.0/Src/exec.c	Sat Jun 23 20:53:45 2001
@@ -2288,9 +2288,6 @@
 #ifdef PATH_DEV_FD
 		closem(2);
 #endif
-		if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) && lastval && !subsh) {
-		    fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
-		}
 		fflush(stdout);
 		if (save[1] == -2) {
 		    if (ferror(stdout)) {
@@ -2299,6 +2296,10 @@
 		    }
 		} else
 		    clearerr(stdout);
+	    }
+	    if (isset(PRINTEXITVALUE) && isset(SHINSTDIN) &&
+		lastval && !subsh) {
+		fprintf(stderr, "zsh: exit %ld\n", (long)lastval);
 	    }
 
 	    if (do_exec) {

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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