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

RE: Redirecting shell output to a pipe

What you want is typescript.

Swisscom AG      Zentweg 9      CH-3006 Ostermundigen
+41 31 342 2141           norman.azadian@xxxxxxxxxxxx

-----Original Message-----
From: Nadav Har'El [mailto:nyh@xxxxxxxxxxxxxxxxxxx] 
Sent: Wednesday, November 25, 2009 2:45 PM
To: Joke de Buhr
Cc: zsh-users@xxxxxxx
Subject: Re: Redirecting shell output to a pipe


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.


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