zsh-workers
 help / color / mirror / code / Atom feed
* stdout bug? (redirection not honored)
@ 2006-11-01 18:41 J.D. Laub
  2006-11-01 18:46 ` Peter Stephenson
  2006-11-01 18:59 ` Danek Duvall
  0 siblings, 2 replies; 5+ messages in thread
From: J.D. Laub @ 2006-11-01 18:41 UTC (permalink / raw)
  To: zsh-workers

Is this a bug?
% uname -s -r -v -m -p -i -o
Linux 2.4.21-32.0.1.ELsmp #1 SMP Tue May 17 17:52:23 EDT 2005 i686 i686 i386 GNU/Linux
% echo $ZSH_VERSION > /dev/null | cat # should print nothing, but...
4.3.2

The problem becomes an issue when you have a command that generates
something on both stdout and stderr, and you want to dump the stdout
and page through the stderr:

% foo 2>&1 > /dev/null | more

I'm hoping someone says this can be addressed by setting an
option.  :-)  I was also able to duplicate it on hpux:
% uname -s -r -v -m -i -l
HP-UX B.11.11 U 9000/800 139414660 unlimited-user license

-- 
J.D. Laub (Laubster) |"Your leg's too long / Your skull's too strong /
zsh-workers@laubster.org| Suppose your nose is wrong." - Renaldo & the Loaf


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: stdout bug? (redirection not honored)
  2006-11-01 18:41 stdout bug? (redirection not honored) J.D. Laub
@ 2006-11-01 18:46 ` Peter Stephenson
  2006-11-01 22:15   ` J.D. Laub
  2006-11-01 18:59 ` Danek Duvall
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2006-11-01 18:46 UTC (permalink / raw)
  To: zsh-workers

"J.D. Laub" wrote:
> Is this a bug?

No, see below.

> % uname -s -r -v -m -p -i -o
> Linux 2.4.21-32.0.1.ELsmp #1 SMP Tue May 17 17:52:23 EDT 2005 i686 i686 i386 
> GNU/Linux
> % echo $ZSH_VERSION > /dev/null | cat # should print nothing, but...
> 4.3.2
> 
> The problem becomes an issue when you have a command that generates
> something on both stdout and stderr, and you want to dump the stdout
> and page through the stderr:
> 
> % foo 2>&1 > /dev/null | more
> 
> I'm hoping someone says this can be addressed by setting an
> option.  :-)

Yes, indeed.

3.26: Why is my output duplicated with `foo 2>&1 >foo.out | bar'?

  This is a slightly unexpected effect of the option MULTIOS, which is
  set by default.  Let's look more closely:

    foo 2>&1 >foo.out | bar

  What you're probably expecting is that the command `foo' sends its
  standard output to the pipe and so to the input of the command `bar',
  while it sends its standard error to the file `foo.out'.  What you
  actually see is that the output is going both to the pipe and into the
  file.  To be more explicit, here's the same example with real commands:

    % { print output; print error >&2 } 2>&1 >foo.out | sed 's/error/erratic'
    erratic
    output
    % cat foo.out
    output

  and you can see `output' appears twice.

  It becomes clearer what's going on if we write:

    % print output >foo1.out >foo2.out
    % cat foo1.out
    output
    % cat foo2.out
    output

  You might recognise this as a standard feature of zsh, called `multios'
  and controlled by the option of the same name, whereby output is copied
  to both files when the redirector appears twice.  What's going on in the
  first example is exactly the same, however the second redirector is
  disguised as a pipe.  So if you want to turn this effect off, you need
  to unset the option `MULTIOS'.


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: stdout bug? (redirection not honored)
  2006-11-01 18:41 stdout bug? (redirection not honored) J.D. Laub
  2006-11-01 18:46 ` Peter Stephenson
@ 2006-11-01 18:59 ` Danek Duvall
  1 sibling, 0 replies; 5+ messages in thread
From: Danek Duvall @ 2006-11-01 18:59 UTC (permalink / raw)
  To: J.D. Laub; +Cc: zsh-workers

On Wed, Nov 01, 2006 at 11:41:28AM -0700, J.D. Laub wrote:

> The problem becomes an issue when you have a command that generates
> something on both stdout and stderr, and you want to dump the stdout
> and page through the stderr:
> 
> % foo 2>&1 > /dev/null | more

See Peter's response re: multios, but note that this command doesn't match
what you described.  It copies stderr to stdout, and then sends it to two
places with multios.  Instead, you probably want

    % foo 2> /dev/null | more

which merely sends stderr to /dev/null and pipes stdout to more.

Danek


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: stdout bug? (redirection not honored)
  2006-11-01 18:46 ` Peter Stephenson
@ 2006-11-01 22:15   ` J.D. Laub
  2006-11-02  1:34     ` Wayne Davison
  0 siblings, 1 reply; 5+ messages in thread
From: J.D. Laub @ 2006-11-01 22:15 UTC (permalink / raw)
  To: zsh-workers

On Wed, Nov 01, 2006 at 06:46:07PM +0000, Peter Stephenson wrote:
>   So if you want to turn this effect off, you need
>   to unset the option `MULTIOS'.

What am I missing with the following?

% unsetopt | grep multios
nomultios
% print $ZSH_VERSION >foo1.out >foo2.out
% cat foo1.out
4.3.2
% cat foo2.out
4.3.2

> 3.26: Why is my output duplicated with `foo 2>&1 >foo.out | bar'?

I had searched for "stdout" and "redirect" in the faq index.  I need
to train myself to troll through all entries if a search doesn't
find what I'm after - sorry for the noise.

-- 
J.D. Laub (Laubster) |"Your leg's too long / Your skull's too strong /
zsh-workers@laubster.org| Suppose your nose is wrong." - Renaldo & the Loaf


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: stdout bug? (redirection not honored)
  2006-11-01 22:15   ` J.D. Laub
@ 2006-11-02  1:34     ` Wayne Davison
  0 siblings, 0 replies; 5+ messages in thread
From: Wayne Davison @ 2006-11-02  1:34 UTC (permalink / raw)
  To: J.D. Laub; +Cc: zsh-workers

On Wed, Nov 01, 2006 at 03:15:35PM -0700, J.D. Laub wrote:
> % unsetopt | grep multios
> nomultios

That means that multios is set because it indicates that nomultios
is unset.

..wayne..


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-11-02  1:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-01 18:41 stdout bug? (redirection not honored) J.D. Laub
2006-11-01 18:46 ` Peter Stephenson
2006-11-01 22:15   ` J.D. Laub
2006-11-02  1:34     ` Wayne Davison
2006-11-01 18:59 ` Danek Duvall

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