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

On May 6, 12:47pm, Bernd Eggink wrote:
} Subject: Re: zsh vs. ksh coproc redirection semantics
}
} 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".
} [...]
} 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.

No, that's not true.  3>&1 means to copy the shell's standard output to
descriptor 3.  3>&p means copy the shell's coproc output to descriptor
3.  3<&0 means copy the shell's standard input to 3.  3<&p means copy the
shell's coproc input to 3 (not move the coproc's input to 3).

Ksh, on the other hand, appears to treat <&p as "the coproc end of the
two-way pipe" and >&p as "the ksh end of the two-way pipe".  This isn't
the same as other descriptors, but then other descriptors aren't pipes.

I think zsh's treatment ends up working a bit more consistently, because
you can always think of descriptor behavior in terms of where the current
shell will get or put data.

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

I still think (based on what you've said in previous messages) that this
particular detail is not very consistent in ksh.  In zsh, if I do
	exec 4<&0
	exec 4<&-
then that closes only descriptor 4, not descriptor 0.  Why should
	exec 3<&p
	exec 3<&-
close both 3 and p?  In ksh, if you do
	exec 4>&p
can you later do
	exec 5>&p
and end up having both 4 and 5 connected to the coproc pipe at the same
time?  My guess is that you can't -- that once you've done 4>&p, then p
is gone and you can't do 5>&p.

Now, the question is, whether this particular inconsistency with p and
other fds is useful enough to emulate it.

(Is anybody on zsh-workers reading this?  Zefram, Zoltan, Peter?)

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

I still think that's completely independent.  It doesn't matter what
descriptors you can connect it to without some kind of special handling
to close the original descriptor at the same time that you close the one
you connected it to.

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1998-05-06 16:12 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
1998-05-06 16:00                           ` Bart Schaefer [this message]
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=980506090047.ZM13585@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=eggink@uni-hamburg.de \
    --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).