From: Zoltan Hidvegi <hzoli@cs.elte.hu>
To: jkelley@algo.ugcs.caltech.edu (Jonathan Kelley)
Cc: zsh-workers@math.gatech.edu
Subject: Re: [zsh 3.0.0 bug] <command> | <builtin> <redirection>
Date: Sat, 14 Dec 1996 03:47:14 +0100 (MET) [thread overview]
Message-ID: <199612140247.DAA03747@hzoli.ppp.cs.elte.hu> (raw)
In-Reply-To: <199612130226.SAA16385@envy.ugcs.caltech.edu> from Jonathan Kelley at "Dec 12, 96 06:26:03 pm"
> Standard input is closed when the redirection in the above
> command template fails.
>
> Example:
>
> algo% zsh -f
> algo% tty
> /dev/ttyq12
> algo% : | : > /
> zsh: invalid argument: /
> algo% tty
> not a tty
It's worse:
hzoli% : < / > foo 2> /
zsh: is a directory: /
hzoli% echo foo
zsh: write error: bad file number
The fix is below.
Zoltan
*** exec.c 1996/12/11 02:27:28 3.1.0.5
--- exec.c 1996/12/14 02:41:28
***************
*** 31,38 ****
#include "zsh.h"
! #define execerr() { if (forked) _exit(1); \
! closemnodes(mfds); lastval = 1; return; }
static LinkList args;
static int doneps4;
--- 31,38 ----
#include "zsh.h"
! #define execerr() if (!forked) { lastval = 1; return; } else _exit(1)
!
static LinkList args;
static int doneps4;
***************
*** 1483,1494 ****
--- 1483,1496 ----
"BUG: unexpanded here document\n");
if (fn->type == INPIPE) {
if (fn->fd2 == -1) {
+ closemnodes(mfds);
fixfds(save);
execerr();
}
addfd(forked, save, mfds, fn->fd1, fn->fd2, 0);
} else if (fn->type == OUTPIPE) {
if (fn->fd2 == -1) {
+ closemnodes(mfds);
fixfds(save);
execerr();
}
***************
*** 1497,1502 ****
--- 1499,1505 ----
if (fn->type != HERESTR && xpandredir(fn, cmd->redir))
continue;
if (errflag) {
+ closemnodes(mfds);
fixfds(save);
execerr();
}
***************
*** 1504,1509 ****
--- 1507,1513 ----
case HERESTR:
fil = getherestr(fn);
if (fil == -1) {
+ closemnodes(mfds);
fixfds(save);
if (errno != EINTR)
zerr("%e", NULL, errno);
***************
*** 1518,1523 ****
--- 1522,1528 ----
else
fil = open(unmeta(fn->name), O_RDWR | O_CREAT, 0666);
if (fil == -1) {
+ closemnodes(mfds);
fixfds(save);
if (errno != EINTR)
zerr("%e: %s", fn->name, errno);
***************
*** 1543,1548 ****
--- 1548,1554 ----
if (fil == -1) {
char fdstr[4];
+ closemnodes(mfds);
fixfds(save);
sprintf(fdstr, "%d", fn->fd2);
zerr("%s: %e", fdstr, errno);
***************
*** 1564,1569 ****
--- 1570,1576 ----
if (fil == -1 || dfil == -1) {
if(fil != -1)
close(fil);
+ closemnodes(mfds);
fixfds(save);
if (errno != EINTR)
zerr("%e: %s", fn->name, errno);
prev parent reply other threads:[~1996-12-14 3:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-12-13 2:26 Jonathan Kelley
1996-12-14 2:47 ` Zoltan Hidvegi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199612140247.DAA03747@hzoli.ppp.cs.elte.hu \
--to=hzoli@cs.elte.hu \
--cc=jkelley@algo.ugcs.caltech.edu \
--cc=zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).