Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Redirecting shell output to a pipe



Hi,

On Wed, Nov 25, 2009, Joke de Buhr wrote about "Re: Redirecting shell output to a pipe":
> > > exec |& tee filename
> 
> you should replace exec with a command. NOT the "exec" builtin. using the 
> builtin exec command doesn't make much sense in this context:

I think there was a misunderstanding here. When I used the word "exec" I
didn't mean it as a replacement for any executable, but rather the specific
keyword "exec". I know all about the syntax for redirection of ordinary
commands (I've been using Unix shells for the past 25 years ;-)).
What I was asking was not about redirecting an invidual command, but rather
redirecting all the shell's output, from now on. The syntax to do that
for redirection to a file is:

	exec > filename

Just like that - with the keyword "exec". It's a bizarre syntax, I admit,
but one that has existed for decades (it is not a zsh-specific feature).
My question was how do you do that - i.e., redirection of all the shell's
output - but not to a file but rather a command, e.g., the command
"tee filename". I was hoping that the following would work:

	exec | tee filename

would work, but it doesn't, and I was wondering if anybody knew why - is
this an oversight or deliberate. I also gave a working, but way too difficult
alternative to achieve the same thing using a coprocess.

Thanks,
Nadav.

-- 
Nadav Har'El                        |    Wednesday, Nov 25 2009, 8 Kislev 5770
nyh@xxxxxxxxxxxxxxxxxxx             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |:(){ :|:&};: # DANGER: DO NOT run this,
http://nadav.harel.org.il           |unless you REALLY know what you're doing!



Messages sorted by: Reverse Date, Date, Thread, Author