From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28683 invoked from network); 5 May 1998 17:09:13 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 5 May 1998 17:09:13 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id NAA26697; Tue, 5 May 1998 13:04:14 -0400 (EDT) Resent-Date: Tue, 5 May 1998 13:03:49 -0400 (EDT) From: "Bart Schaefer" Message-Id: <980505100306.ZM9156@candle.brasslantern.com> Date: Tue, 5 May 1998 10:03:05 -0700 In-Reply-To: Comments: In reply to Bernd Eggink "Re: exit value of intermediate program in pipe" (May 5, 1:39pm) References: X-Mailer: Z-Mail (4.0b.820 20aug96) To: Bernd Eggink Subject: zsh vs. ksh coproc redirection semantics Cc: Bernd Eggink , zsh-users@math.gatech.edu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Resent-Message-ID: <"NdJWe3.0.QW6.qPqJr"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1518 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On May 5, 1:39pm, Bernd Eggink wrote: } Subject: Re: exit value of intermediate program in pipe } } On Mon, 4 May 1998, Bart Schaefer wrote: } } > cat <&p } > } > what happens? The input _of cat_ is connected to the _output_ of the } > coproc, right? } } Hm, I admit that I never tried this in zsh... In fact, it works } like this in zsh, but exactly the OTHER way round in ksh. So you're saying that in ksh, cat <&p means that the coproc input is closed and cat takes its input from wherever the coproc was getting its input? That makes no sense at all. (Which tells me that `exec 3<&p` must be doing something special in ksh, if indeed it acts as you say.) } In ksh 3<&p means "duplicate the coproc input to unit 3". I think maybe we're having a cognitive dissonance here. The coproc is a two-way pipe: out +--- zsh ----+ in | | >&p <&p | | in +-- coproc --+ out According to what you're saying, ksh does it like this: in +--- ksh ----+ out | | >&p <&p | | in +-- coproc --+ out Is that correct? } IMHO this is more consistent and intuitive than what zsh does. Really? I think having inputs connected to outputs is more intuitive than having inputs duplicated. } After looking into the doc, I even suspect that this may be a bug... } Quoting from chapter 6, "redirection": } } <&p } >&p The input/output from/to the coprocess is moved to the } standard input/output. } } If 'input' corresponds to <&p, this is fact what ksh does and what } zsh DOESN'T! Re-parse that doc: <&p The input from the coprocess is moved to the standard input. >&p The output to the coprocess is moved to the standard output. Note "input _from_" not "input of", and "output _to_" not "output of". out to +--- zsh ----+ in from | | >&p <&p | | in of +-- coproc --+ out of This may be the reverse of what ksh does, but I think zsh's doc tells accurately (if not all that clearly) how zsh behaves. However, I'm really surprised to hear that this is backwards in ksh. That seems completely unintuitive to me. If I say cat <&3 That means I want cat to read from fd 3, does it not? So if I say cat <&p That should mean I want cat to read from the coproc. Which should mean that <&p refers to "the input _from_ the coproc" which means the output _of_ the coproc. No? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com