* [zsh 3.0.0 bug] <command> | <builtin> <redirection>
@ 1996-12-13 2:26 Jonathan Kelley
1996-12-14 2:47 ` Zoltan Hidvegi
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Kelley @ 1996-12-13 2:26 UTC (permalink / raw)
To: zsh-workers
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
algo% uname -a
IRIX algo 5.3 11091812 IP22 mips
Jonathan Kelley
jkelley@ugcs.caltech.edu
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [zsh 3.0.0 bug] <command> | <builtin> <redirection>
1996-12-13 2:26 [zsh 3.0.0 bug] <command> | <builtin> <redirection> Jonathan Kelley
@ 1996-12-14 2:47 ` Zoltan Hidvegi
0 siblings, 0 replies; 2+ messages in thread
From: Zoltan Hidvegi @ 1996-12-14 2:47 UTC (permalink / raw)
To: Jonathan Kelley; +Cc: zsh-workers
> 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-12-14 3:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-12-13 2:26 [zsh 3.0.0 bug] <command> | <builtin> <redirection> Jonathan Kelley
1996-12-14 2:47 ` Zoltan Hidvegi
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).