* Function output re-direction
@ 1996-08-02 18:42 Vinnie Shelton
1996-08-03 2:39 ` Zoltan Hidvegi
0 siblings, 1 reply; 2+ messages in thread
From: Vinnie Shelton @ 1996-08-02 18:42 UTC (permalink / raw)
To: zsh-workers
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 on Solaris 2.5, built with the Sparcworks 4.1 compiler.
--vin
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Function output re-direction
1996-08-02 18:42 Function output re-direction Vinnie Shelton
@ 1996-08-03 2:39 ` Zoltan Hidvegi
0 siblings, 0 replies; 2+ messages in thread
From: Zoltan Hidvegi @ 1996-08-03 2:39 UTC (permalink / raw)
To: acs; +Cc: zsh-workers
> 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 {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-08-03 2:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-02 18:42 Function output re-direction Vinnie Shelton
1996-08-03 2:39 ` 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).