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

PATCH: coprocess descriptor and error messages



This seems somehow wrong to me ... starting from "zsh -f":

torch% print -p ; echo $?
print: bad file number: -1
1
torch% read -p ; echo $?
1

Seems to me that both commands should either fail silently, or print a
more specific error.  Patch below does the former.  (Line numbers may
be off.)  I won't commit until I see commentary.

Index: Src/builtin.c
===================================================================
RCS file: /extra/cvsroot/zsh/zsh-4.0/Src/builtin.c,v
retrieving revision 1.48
diff -c -r1.48 builtin.c
--- builtin.c	17 Apr 2009 18:57:22 -0000	1.48
+++ builtin.c	17 Sep 2010 05:02:15 -0000
@@ -3677,13 +3720,17 @@
     if (OPT_HASARG(ops,'u') || OPT_ISSET(ops,'p')) {
 	int fd;
 
-	if (OPT_ISSET(ops, 'p'))
+	if (OPT_ISSET(ops, 'p')) {
 	    fd = coprocout;
-	else {
+	    if (fd < 0)
+		return 1;
+	} else {
 	    char *argptr = OPT_ARG(ops,'u'), *eptr;
 	    /* Handle undocumented feature that -up worked */
 	    if (!strcmp(argptr, "p")) {
 		fd = coprocout;
+		if (fd < 0)
+		    return 1;
 	    } else {
 		fd = (int)zstrtol(argptr, &eptr, 10);
 		if (*eptr) {


-- 



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