From: "Jérémie Roquet" <arkanosis@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: $pipestatus and shell functions
Date: Mon, 11 Apr 2011 17:52:24 +0200 [thread overview]
Message-ID: <BANLkTimLwZCd462OWiNCt9Qb6hJAptmJ7Q@mail.gmail.com> (raw)
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
next reply other threads:[~2011-04-11 16:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-11 15:52 Jérémie Roquet [this message]
2011-04-11 16:38 ` Peter Stephenson
2011-04-11 16:48 ` Peter Stephenson
2011-04-11 17:33 ` Jérémie Roquet
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=BANLkTimLwZCd462OWiNCt9Qb6hJAptmJ7Q@mail.gmail.com \
--to=arkanosis@gmail.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).