bug-bash
[Top][All Lists]
Advanced

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

Re: redirection inside a process-substitution


From: Helmut Karlowski
Subject: Re: redirection inside a process-substitution
Date: Tue, 23 Aug 2016 23:00:56 +0200
User-agent: Opera Mail/12.17 (Win32)

Am 23.08.2016, 17:00 Uhr, schrieb Chet Ramey:

It has to do when things are processed.  Process substitution is not a
command or a redirection: it is a word expansion that expands to a file
name.  Word expansions are performed before redirections.

Sure: similar to command-substitution as mentioned by Pierre. Bash does it right, I was wrong.

Now extending Pierre's example:

exec 3>tb.err
echo 3>&1 > >(echo 1 1>&3)
echo +++++
cat tb.err
echo -----
echo 3>&1 > >(echo 11 1>&3)
echo +++++
cat tb.err
echo -----
echo > >(echo 2 1>&3) 3>&1
echo +++++
echo -----
cat tb.err
echo > >(echo 3 1>&3)
echo +++++
cat tb.err
echo -----
wait

I get in bash:

1

in ksh93 (where > >() does not work anyway, at least on cygwin):

+++++
-----
+++++
-----
+++++
-----
+++++
-----

in zsh (sometimes, sometimes it prints nothing):

+++++
1
-----
+++++
1
11
-----
-----
+++++
-----
1
11
2
+++++
1
11
2
3
-----

The zsh-output looks most reasonable to me: The sub-process redirects stdout to 3 which is connected to the file. So all sub-process-output gets appended to the file. The main-echo-output goes nowhere because the sub-echo does not read.

I might be wrong again ;)

Thanks,

-Helmut



reply via email to

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