Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: |& loses data (buffering bug?)



On Fri, 13 Feb 2004 16:44:09 +0100
Vincent Lefevre <vincent@xxxxxxxxxx> wrote:

> On 2004-02-13 16:30:31 +0100, Vincent Lefevre wrote:
> > On 2004-02-13 15:00:16 +0000, Peter Stephenson wrote:
> > > Can you get the same effect with e.g.
> > > 
> > >   perl -e 'open STDERR, ">&STDOUT";
> > >   open STDIN, "cvs status|";
> > > 
> > >   exec "less";'
> > > 
> > > which doesn't involve zsh at all?
>
> In fact, it doesn't do the same thing: STDERR is redirected to the
> terminal here.

You're right, the output from less is being redirected, not the output to
less.  Also, the tricks with pipes don't quite match what zsh is doing.
That's something more like:

perl -e 'pipe PIN, POUT;
if (fork) {
  close POUT;
  open STDIN, "<&PIN";
  close PIN;

  $_ = <STDIN>;
  exec "less";
} else {
  close PIN;
  open STDOUT, ">&POUT";
  open STDERR, ">&POUT";
  close POUT;

  $| = 1;
  print STDOUT "Sync\n";
  exec "cvs status";
}'

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author