Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Function output re-direction
- X-seq: zsh-workers 1909
- From: Zoltan Hidvegi <hzoli@xxxxxxxxxx>
- To: acs@xxxxxxxxxxxxx
- Subject: Re: Function output re-direction
- Date: Sat, 3 Aug 1996 04:39:06 +0200 (MET DST)
- Cc: zsh-workers@xxxxxxxxxxxxxxx
- In-reply-to: <199608021842.OAA07896@xxxxxxxxxxxxxxxxxxxxxxxx> from Vinnie Shelton at "Aug 2, 96 02:42:28 pm"
- Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary
- Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368
> I've stumbled across a rather bad bug in pre5. I haven't applied any of the
> patches yet, so if this has already been fixed, feel free to ignore this
> message. When I pipe input to a shell function and re-direct the output,
> stdout of the shell is re-directed as well:
>
> spacely% zsh -f
> spacely% echo $ZSH_VERSION
> 3.0-pre5
> spacely% function x {
> > echo x
> > }
> spacely% x
> x # OK so far
> spacely% ls | x >/dev/null
> spacely% ls # Output is gone!
> spacely% exec >/dev/tty # got it back
This is fixed by the patch below but I'm not really pleased with that
patch. The problem was that addfd() closed subsh_close (moved it to the
input of the x function). Then the redirection daved the stdout and it
replaced the just closed subsh_close and later a zclose(subsh_close) was
executed which closed the original stdout forever.
I'm not pleased with that because I do not really understand this
subsh_close variable and I do not like it because it is a static variable
which may be changed by a trap function. To avoid that I added it to
execstack.
Zoltan
*** Src/exec.c 1996/08/02 13:37:11 2.79
--- Src/exec.c 1996/08/03 02:34:47
***************
*** 1025,1030 ****
--- 1025,1032 ----
} else /* add another fd to an already split stream */
mfds[fd1]->fds[mfds[fd1]->ct++] = movefd(fd2);
}
+ if (!fdtable[subsh_close])
+ subsh_close = -1;
}
/**/
***************
*** 2650,2655 ****
--- 2652,2658 ----
es->cmdoutval = cmdoutval;
es->trapreturn = trapreturn;
es->noerrs = noerrs;
+ es->subsh_close = subsh_close;
es->next = exstack;
exstack = es;
noerrs = cmdoutpid = 0;
***************
*** 2677,2682 ****
--- 2680,2686 ----
cmdoutval = exstack->cmdoutval;
trapreturn = exstack->trapreturn;
noerrs = exstack->noerrs;
+ subsh_close = exstack->subsh_close;
en = exstack->next;
free(exstack);
exstack = en;
*** Src/zsh.h 1996/07/31 15:45:25 2.40
--- Src/zsh.h 1996/07/31 13:40:59
***************
*** 606,611 ****
--- 606,612 ----
int cmdoutval;
int trapreturn;
int noerrs;
+ int subsh_close;
};
struct heredocs {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author