help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] stdout and stderr to two different process substitutions


From: Peng Yu
Subject: Re: [Help-bash] stdout and stderr to two different process substitutions
Date: Wed, 25 Jan 2012 13:51:39 -0600

On Wed, Jan 25, 2012 at 1:04 PM, Greg Wooledge <address@hidden> wrote:
> On Wed, Jan 25, 2012 at 12:36:24PM -0600, Peng Yu wrote:
>> OK. To summarize concisely, it appears to be that there are only
>> "global" stdout and stderr, but stdin is local.
>
> No.  That is not a fair summary at all.
>
> Every process has its *own* FDs -- stdin, stdout, stderr, plus any that
> it opens.  These can be separate, or they can be the same.
>
>> foo  > >(gzip > xx.gz) 2> >(tee yy 1>&2)
>
> 1) gzip is run in the background.  Its stdout goes to xx.gz.  Its input
>   is connected to a pipe (call it "A").
>
> 2) foo's output is redirected to pipe A.
>
> 3) tee is run in the background.  Its stdout is redirected to its stderr,
>   which it inherited from foo.  Its input is connected to pipe "B".
>
> 4) foo's stderr is redirected to pipe B.
>
> I really can't explain it any more clearly than that.  Those 4 things
> occur *in that order*.  It cannot be simplified any more than that
> without misrepresenting what's occurring in the software.
>
> There is certainly no "global stdout".  FDs are inherited, but then they
> can be closed or redirected.

OK. I see my mistake. But I still don't understand why stdout of tee
goes to stdout of foo, hence redirected to the stdin of gzip hence
goes to xx.gz. This appears to be that tee and foo share the same
stdout.

foo > >(gzip >xx.gz) 2> >(tee yy)

-- 
Regards,
Peng



reply via email to

[Prev in Thread] Current Thread [Next in Thread]