zsh-workers
 help / Atom feed
* pipelines transmitting data even after redirecting stdout
@ 2019-05-31  3:35 Kartik Agaram
  2019-05-31  4:33 ` Philippe Troin
  0 siblings, 1 reply; 2+ messages in thread
From: Kartik Agaram @ 2019-05-31  3:35 UTC (permalink / raw)
  To: zsh-workers

In the rest of this message I'm running within a zsh sub-process
without any dotfiles or inherited environment variables:

env -i zsh -f

This command works as expected:

% echo abc > /dev/null
%   # no output

However, adding another pipestage to it is unexpected:

% echo abc > /dev/null |cat
abc  # whoa!

If I redirect stdout to a file I seem to get some `tee`-like behavior for free:

% echo abc >x |cat
abc
% cat x
abc

Is this somehow expected behavior? I've tested it on the following
systems and gotten identical results:

1. zsh 5.7.1 (x86_64-apple-darwin18.2.0) on Mac OS 10.14.5
2. zsh 5.4.2 on Ubuntu 18.04

(Please explicitly include my email address in responses.)

Thank you,
Kartik
http://akkartik.name/about

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

* Re: pipelines transmitting data even after redirecting stdout
  2019-05-31  3:35 pipelines transmitting data even after redirecting stdout Kartik Agaram
@ 2019-05-31  4:33 ` Philippe Troin
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Troin @ 2019-05-31  4:33 UTC (permalink / raw)
  To: Kartik Agaram, zsh-workers

On Thu, 2019-05-30 at 20:35 -0700, Kartik Agaram wrote:
> This command works as expected:
> 
> % echo abc > /dev/null
> %   # no output
> 
> However, adding another pipestage to it is unexpected:
> 
> % echo abc > /dev/null |cat
> abc  # whoa!
> 
> If I redirect stdout to a file I seem to get some `tee`-like behavior for free:
> 
> % echo abc >x |cat
> abc
> % cat x
> abc
> 
> Is this somehow expected behavior?

Yes, it's a feature called multios, check the zsh manpage MULTIOS
section for details or 
http://zsh.sourceforge.net/Doc/Release/Redirection.html#Multios

Phil.


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31  3:35 pipelines transmitting data even after redirecting stdout Kartik Agaram
2019-05-31  4:33 ` Philippe Troin

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/ public-inbox