[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] stdout and stderr to two different process substitutions
From: |
Greg Wooledge |
Subject: |
Re: [Help-bash] stdout and stderr to two different process substitutions |
Date: |
Wed, 25 Jan 2012 11:04:22 -0500 |
User-agent: |
Mutt/1.4.2.3i |
On Wed, Jan 25, 2012 at 09:50:35AM -0600, Peng Yu wrote:
> > pipe A leads to gzip, whose stdout goes to the file xx.gz. Special pipe
> > B leads to tee, which writes a copy of the piped input to the file yy,
> > and another copy of the piped input to the screen (foo's stderr).
>
> This looks a little wired to me. I though that the last "2" refers to
> the stderr of tee, but it actually refers to the stderr of the main
> process?
tee inherits stderr from the script, *before* the script's stderr is
redirected to the special pipe. So writing to tee's stderr is basically
writing to the script's stderr before it gets modified.
> Note: I'm a little confused whether it should be tee's stdout or the
> main stdout. It seems to be tee's stdout, as I don't see any output
> from
>
> { echo STDOUT ; echo STDERR 1>&2 ;} > >(gzip > xx.gz) 2> >(tee yy)
>
> But this sees to be asymmetric, why tee's stdout is redirected to the
> main stderr but not tee' stderr?
First, let's observe what it actually does:
imadev:~$ cat yy
STDERR
imadev:~$ zcat xx.gz
STDOUT
STDERR
The only explanation which can account for that behavior is that the
process substitutions are not all done at the same time.
foo > >(gzip) 2> >(tee)
^ ^ ^ ^
| | | |
2 1 4 3
It appears that each process substitution is done immediately before its
accompanying redirection. In order 1 2 3 4 as shown in the diagram.
So, foo's (the script's) stdout has already been redirected (step 2) at
the time the process substitution for tee is performed (step 3). Which
means tee inherits the modified stdout, and the pristine stderr.
- Re: [Help-bash] stdout and stderr to two different process substitutions, (continued)
- Re: [Help-bash] stdout and stderr to two different process substitutions, Bob Proulx, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Pierre Gaston, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Bob Proulx, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Greg Wooledge, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Greg Wooledge, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions,
Greg Wooledge <=
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Greg Wooledge, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Greg Wooledge, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Chet Ramey, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Bob Proulx, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Greg Wooledge, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Bob Proulx, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Peng Yu, 2012/01/25
- Re: [Help-bash] stdout and stderr to two different process substitutions, Chet Ramey, 2012/01/25