Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
$pipestatus and shell functions
- X-seq: zsh-users 15954
- From: Jérémie Roquet <arkanosis@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: $pipestatus and shell functions
- Date: Mon, 11 Apr 2011 17:52:24 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=u6r7uDtL70eNqc1yW3/Q7sZjNhMs4bpdbCAjwvdwMVs=; b=dq6lJokqfVWc14tYmckRlcMeyre6cNTs0BflYWqR7Vb8bsza02kqirVGj3M1KWclY/ +dS3HgdWyodnz4w4gkGz0cgypBQpFbSnTxp5wUtk/Fag6QVFgwl4SiAYbvdBysuVMTQk aC1dqPFw4Jk3HWwkvKPbL5F62yJu5t7uRU57c=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; b=fHz8Iv8zis8NogXGBhVq4Hu/Bxch6vNzC0yGHBVnGARSDw+t3+Iy4xk5rOQgBhs59r KQ34EMkGlX3CVrZosIuEN9+HP4In7uRKFphmEOcWBofgf/qT+PxQ58cLmrpJqDHeM7kW dqwjhwaVbxkybLNqnqCHa6bFagYizmcc3i5bQ=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author