zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: multios doesn't work with 2>&1
Date: Sun, 27 Oct 2013 10:01:37 -0700	[thread overview]
Message-ID: <131027100137.ZM4100@torch.brasslantern.com> (raw)
In-Reply-To: <20131027145917.GA5509@localhost.localdomain>

On Oct 27, 10:59pm, Han Pingtian wrote:
} 
} According to the zsh guide's "2.5.8 `Go faster' options for power
} users", page 44:
} 
}     % echo foo 2>&1 >/dev/null | sed 's/foo/bar/'
} 
} should output "bar" if multios has been set. But it outputs nothing

Hmm, looks like this has been broken for a LONG time.

If I back out workers/20666 (Jan 2005), then this example works again.

Note that

    % print -u2 foo 2>&1 >/dev/null | sed 's/foo/bar/'

does print "bar", so the problem is that the original fd 1 is directed
to /dev/null while the multio fd created by 2>&1 is is directed to the
pipe.  You can see the reasoning for this in the "references" thread
going back from http://www.zsh.org/mla/workers/2005/msg00026.html

The workaround is to either explicitly add the original stdout to the
multio: 

    % echo foo 2>&1 >&1 >/dev/null | sed 's/foo/bar/'

Or to make sure the multio isn't created until the pipe is seen:

    % { echo foo 2>&1 } >/dev/null | sed 's/foo/bar/'

If there's a way to fix the original complaint (that >&- doesn't really
close the descriptor when a multio is involved, so unnecessary multios
result) without the above example remaining broken, I may need some help
to find it.

Otherwise we have to decide whether to revert to the pre-2005 behavior,
or document around it.


      reply	other threads:[~2013-10-27 17:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-27 14:59 Han Pingtian
2013-10-27 17:01 ` Bart Schaefer [this message]

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=131027100137.ZM4100@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /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).