zsh-users
 help / color / mirror / code / Atom feed
* $pipestatus and shell functions
@ 2011-04-11 15:52 Jérémie Roquet
  2011-04-11 16:38 ` Peter Stephenson
  0 siblings, 1 reply; 4+ messages in thread
From: Jérémie Roquet @ 2011-04-11 15:52 UTC (permalink / raw)
  To: Zsh Users

Hello,

I'm somewhat confused by the behaviour of the $pipestatus variable:

$ true | true ; echo $pipestatus
0 0
$ false | true ; echo $pipestatus
1 0
$ true | false ; echo $pipestatus
0 1
$ false | false ; echo $pipestatus
0 0
$ foo() { true }
$ true | foo ; echo $pipestatus
0 0
$ false | foo ; echo $pipestatus
1 0

So far, everything is fine for me, but then:

$ foo() { false | true }
$ true | foo ; echo $pipestatus
1 0
$ foo() { false | false }
$ true | foo ; echo $pipestatus
1 1
$ foo() { true | true | true }
$ false | foo ; echo $pipestatus
0 0 0

So $pipestatus is defeated by multiple pipelining…

Is this by design? If so, is there some not-so-complicated workaround
to get the exit code of process A in “ A | B ” for any B (ie. even if
B is itself a shell function with a pipe)?

Thanks in advance, best regards,

-- 
Jérémie


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

end of thread, other threads:[~2011-04-11 17:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-11 15:52 $pipestatus and shell functions Jérémie Roquet
2011-04-11 16:38 ` Peter Stephenson
2011-04-11 16:48   ` Peter Stephenson
2011-04-11 17:33     ` Jérémie Roquet

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