From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12877 invoked by alias); 17 Sep 2010 05:05:16 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28265 Received: (qmail 5292 invoked from network); 17 Sep 2010 05:05:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <100916220444.ZM30547@torch.brasslantern.com> Date: Thu, 16 Sep 2010 22:04:42 -0700 X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: PATCH: coprocess descriptor and error messages MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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) { --