about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Src/builtin.c16
2 files changed, 13 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 6c6dbef92..0c04ac112 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-07-29  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* 17891: Src/builtin.c: fix error message for invalid file
+	descriptor in "print -u".
+
 2013-07-28  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* Manuel Presnitz: 31592 (with minor changes of phrasing):
diff --git a/Src/builtin.c b/Src/builtin.c
index 8516acd81..ae2e9f676 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3792,11 +3792,11 @@ bin_print(char *name, char **args, Options ops, int func)
 
     /* -u and -p -- output to other than standard output */
     if (OPT_HASARG(ops,'u') || OPT_ISSET(ops,'p')) {
-	int fd;
+	int fdarg, fd;
 
 	if (OPT_ISSET(ops, 'p')) {
-	    fd = coprocout;
-	    if (fd < 0) {
+	    fdarg = coprocout;
+	    if (fdarg < 0) {
 		zwarnnam(name, "-p: no coprocess");
 		return 1;
 	    }
@@ -3804,13 +3804,13 @@ bin_print(char *name, char **args, Options ops, int func)
 	    char *argptr = OPT_ARG(ops,'u'), *eptr;
 	    /* Handle undocumented feature that -up worked */
 	    if (!strcmp(argptr, "p")) {
-		fd = coprocout;
-		if (fd < 0) {
+		fdarg= coprocout;
+		if (fdarg < 0) {
 		    zwarnnam(name, "-p: no coprocess");
 		    return 1;
 		}
 	    } else {
-		fd = (int)zstrtol(argptr, &eptr, 10);
+		fdarg = (int)zstrtol(argptr, &eptr, 10);
 		if (*eptr) {
 		    zwarnnam(name, "number expected after -%c: %s", 'u',
 			     argptr);
@@ -3819,8 +3819,8 @@ bin_print(char *name, char **args, Options ops, int func)
 	    }
 	}
 
-	if ((fd = dup(fd)) < 0) {
-	    zwarnnam(name, "bad file number: %d", fd);
+	if ((fd = dup(fdarg)) < 0) {
+	    zwarnnam(name, "bad file number: %d", fdarg);
 	    return 1;
 	}
 	if ((fout = fdopen(fd, "w")) == 0) {