summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2010-09-19 19:20:33 +0000
committerBart Schaefer <barts@users.sourceforge.net>2010-09-19 19:20:33 +0000
commit9530331b4f04015eb65341c97940f68774ab210b (patch)
tree05b9073dd36835c93eb6cbeaaf2fc7d8753aa1dc
parentdd061dc2ce8aed2145c00c620a541be2b0d92784 (diff)
downloadzsh-9530331b4f04015eb65341c97940f68774ab210b.tar.gz
zsh-9530331b4f04015eb65341c97940f68774ab210b.tar.xz
zsh-9530331b4f04015eb65341c97940f68774ab210b.zip
28268: I/O to a terminated (or never created) coprocess emits a
"no coprocess" diagnostic, instead of either nothing or "bad file number".
-rw-r--r--ChangeLog8
-rw-r--r--Src/builtin.c20
2 files changed, 25 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 7bb240412..07185d28b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-09-19  Barton E. Schaefer  <schaefer@zsh.org>
+
+	* 28268: Src/builtin.c: I/O to a terminated (or never created)
+	coprocess emits a "no coprocess" diagnostic, instead of either
+	nothing or "bad file number".
+
 2010-09-16  Peter Stephenson  <pws@csr.com>
 
 	* Baptiste: 28264: Completion/Unix/Command/_ffmpeg: remove the
@@ -13656,5 +13662,5 @@
 
 *****************************************************
 * This is used by the shell to define $ZSH_PATCHLEVEL
-* $Revision: 1.5083 $
+* $Revision: 1.5084 $
 *****************************************************
diff --git a/Src/builtin.c b/Src/builtin.c
index 6dbd1597f..f80269846 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3720,13 +3720,21 @@ bin_print(char *name, char **args, Options ops, int func)
     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) {
+		zwarnnam(name, "-p: no coprocess");
+		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) {
+		    zwarnnam(name, "-p: no coprocess");
+		    return 1;
+		}
 	    } else {
 		fd = (int)zstrtol(argptr, &eptr, 10);
 		if (*eptr) {
@@ -5091,6 +5099,10 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
 	/* The old code handled -up, but that was never documented. Still...*/
 	if (!strcmp(argptr, "p")) {
 	    readfd = coprocin;
+	    if (readfd < 0) {
+		zwarnnam(name, "-p: no coprocess");
+		return 1;
+	    }
 	} else {
 	    readfd = (int)zstrtol(argptr, &eptr, 10);
 	    if (*eptr) {
@@ -5105,6 +5117,10 @@ bin_read(char *name, char **args, Options ops, UNUSED(int func))
 	izle = 0;
     } else if (OPT_ISSET(ops,'p')) {
 	readfd = coprocin;
+	if (readfd < 0) {
+	    zwarnnam(name, "-p: no coprocess");
+	    return 1;
+	}
 	izle = 0;
     } else
 	readfd = izle = 0;