From 9530331b4f04015eb65341c97940f68774ab210b Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Sun, 19 Sep 2010 19:20:33 +0000 Subject: 28268: I/O to a terminated (or never created) coprocess emits a "no coprocess" diagnostic, instead of either nothing or "bad file number". --- ChangeLog | 8 +++++++- Src/builtin.c | 20 ++++++++++++++++++-- 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 + + * 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 * 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; -- cgit 1.4.1