zsh-users
 help / color / mirror / code / Atom feed
From: Bernd Eggink <eggink@uni-hamburg.de>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-users@math.gatech.edu
Subject: Re: zsh vs. ksh coproc redirection semantics
Date: Wed, 06 May 1998 12:47:29 +0200	[thread overview]
Message-ID: <35503FC1.118B229E@uni-hamburg.de> (raw)
In-Reply-To: <980505100306.ZM9156@candle.brasslantern.com>

Bart Schaefer wrote:
> 
> 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. 
[ ... ]

Possibly... I'll try to be more specific:

In ksh, 3<&p means "duplicate the input _the coproc is reading from_ to
3". I consider that consistent with the fact that (in ksh as well as in
zsh) 3<&0 means "duplicate the input that is currently read from to 3".
Of course it doesn't make much sense to copy an input, except for the
purpose of closing it. And you must duplicate the coproc input for
closing, unless a special syntax is provided for that purpose; you can't
say "exec p<&-", because that, of course, would mean something
completely different.

> } 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.

In ksh, the connection is done by 'read -p' and 'print -p'. You can't
say "print foo >&p" or "read bar <&p", whereas in zsh you can say either
"print -p foo" or "print foo >&p". What I meant by "inconsistency" is
that in zsh >& and <& mean different things, depending on whether a 'p'
or a digit follows. This may be considered a matter of convention, but
in effect it prevents you from duplicating the coproc input, and such
from closing it (which, if I remember right, was your original problem).

As I just noticed, ksh has it's inconsistencies, too. While you can't
say "print foo >&p", you can say "exec 4>&p; print foo >&4", and it
works. Hm...

Reconsidering all that, I think the idea of connecting the coproc's
output and input to arbitrary file descriptors would in fact be the most
elegant solution.

Regards,
	Bernd

--
Bernd Eggink
Regionales Rechenzentrum der Uni Hamburg
eggink@rrz.uni-hamburg.de
http://www.rrz.uni-hamburg.de/eggink/BEggink.html


  reply	other threads:[~1998-05-06 11:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-02 22:24 exit value of intermediate program in pipe Steve Talley
1998-05-03  0:50 ` Sweth Chandramouli
1998-05-03  1:38 ` Timothy J Luoma
1998-05-03  2:08 ` Bart Schaefer
1998-05-03  6:17   ` Sweth Chandramouli
1998-05-03  9:30     ` Bart Schaefer
1998-05-03 22:15       ` Sweth Chandramouli
1998-05-04  1:35         ` Bart Schaefer
1998-05-04  4:54           ` Sweth Chandramouli
1998-05-04  9:43             ` Bernd Eggink
1998-05-04 11:42               ` Bart Schaefer
1998-05-04 12:03                 ` Bernd Eggink
1998-05-04 15:59                   ` Bart Schaefer
1998-05-05 11:39                     ` Bernd Eggink
1998-05-05 17:03                       ` zsh vs. ksh coproc redirection semantics Bart Schaefer
1998-05-06 10:47                         ` Bernd Eggink [this message]
1998-05-06 16:00                           ` Bart Schaefer
1998-05-07  7:17                             ` Zoltan Hidvegi
1998-05-07  8:34                               ` Andrew Main
1998-05-07  9:26                                 ` Bart Schaefer
1998-05-07  9:34                                   ` Andrew Main
1998-05-07 17:02                                   ` Zoltan Hidvegi
1998-05-07  9:18                               ` Bart Schaefer
1998-05-07 17:10                                 ` Zoltan Hidvegi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=35503FC1.118B229E@uni-hamburg.de \
    --to=eggink@uni-hamburg.de \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-users@math.gatech.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).