On Thu, 8 Jan 2009, Edmund R. MacKenty wrote:

> On Thursday 08 January 2009 14:13, John McKown wrote:
> >Well, shoot. That never even occurred to me. What I thought that would do
> >was:
> >
> >Change stderr to go where stdout currently goes, then change stdout to go
> >into the pipe. I based this on the fact that if I do:
> >
> >command 2>&1 1>x.tmp
> >
> >Then stderr still comes to my terminal. It does not go to x.tmp.  I guess
> >there is some special code in bash to recognize the redirection & piping
> >as "special".
>
> Actually, there's no special case for this.  The rule is that the shell
> processes I/O redirections left-to-right.  The "2>&1" syntax just means" make
> file descriptor 2 (stderr) refer to whatever file descriptor 1 (stdout)
> refers to.  It doesn't change stdout at all.  File descriptor 1 already
> refers to the pipe because the shell creates the pipes as it is parsing the
> pipeline, before it parses the simple commands within the pipeline.
>
> I hope that makes sense! :-)
>       - MacK.

Ah! The little light goes on. That makes perfect sense. I was simply
parsing the command from left to right, so that the redirection happened
before the pipe, in my mind.

--
Q: What do theoretical physicists drink beer from?
A: Ein Stein.

Maranatha!
John McKown

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to lists...@vm.marist.edu with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390

Reply via email to