zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Zoltan Hidvegi <hzoli@cs.elte.hu>
Cc: zsh-users@math.gatech.edu
Subject: Re: zsh vs. ksh coproc redirection semantics
Date: Thu, 7 May 1998 02:18:06 -0700	[thread overview]
Message-ID: <980507021807.ZM16856@candle.brasslantern.com> (raw)
In-Reply-To: <199805070717.CAA02705@hzoli.home>

On May 7,  2:17am, Zoltan Hidvegi wrote:
} Subject: Re: zsh vs. ksh coproc redirection semantics
}
} Let me quote the ksh manual:
} 
}        <&digit-      The file descriptor given by digit is  moved
}                      to  standard input.  Similarly for the stan­
}                      dard output using >&digit-.
} 
}        <&-           The standard input is closed.  Similarly for
}                      the standard output using >&-.

I'm curious.  In zsh and bash (which also lacks the <&digit- form), <&-
closes the standard input of whatever command it suffixes, not of the
shell itself.  Which must mean that (semantically, if not in actual
implementation) stdin is first dup'd (as it always is when running a
new command) and then the dup is closed.

Is that what happens in ksh?

Is that what happens to fd `digit' in the <&digit- form in ksh?  I.e.,
does `digit' actually go away for good only upon `exec <&digit-` ?

If not, does
	cat <&0-
close the shell's standard input (leaving it connected to cat)?

If so, all I can say is, ick.  Yet, if you take `p' to be shorthand
for "the digit that is connected to the coproc, followed by `-'"
then that's the behavior of

}        <&p           The  input  from  the co-process is moved to
}                      standard input.
} 
}        >&p           The output to the  co-process  is  moved  to
}                      standard output.

which seems like yet another potential inconsistency that zsh might be
better off not having.

Incidentally, that documentation matches what zsh does much closer than
it matches what Bernd Eggink described ksh as doing.  According to that
excerpt, `exec 3<&p 3<&-` should have no effect on the input _of_ the
coprocess.

} Bart wrote:
} > 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'm not sure I understand what you mean here.  Looks like you are
} confused about terms.

No, I know all that stuff about pipes.  I was trying to express concepts
that it seemed ksh wanted those redirections to embody, rather than the
way it has to be implemented underneath.  But now that I see the doc, I
think Bernd's description was of a ksh that got its own implementation
wrong, which is why my attempt to explain it doesn't work either.

} About the job table: ksh places the coprocess to the job table similarily
} to zsh.  You can bring the coprocess to the foregroung with fg, which
} does not makes much sense, but works.

Probably fg followed by ctrl-C is a common kill-the-coproc technique.

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


  parent reply	other threads:[~1998-05-07  9:26 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
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 [this message]
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=980507021807.ZM16856@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=hzoli@cs.elte.hu \
    --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).