Re: git fails with a broken pipe when one quits the pager
- From
- Vincent Lefevre <vincent@vinc17.net>
- Date
- Feb 4, 2021, 15:38 UTC
- Message-ID
- <20210204153812.GI148009@zira.vinc17.org>
- In-Reply-To
- <87v9b8d6zx.fsf@evledraar.gmail.com>
On 2021-02-04 01:14:10 +0100, Ævar Arnfjörð Bjarmason wrote:
> Have you reported this as a bug to zsh?
I repeat: there is no bug in zsh. It is my choice to output the exit status when it is non-zero because I want to know when the command I've typed fails. This is useful in practice. Ignoring the specific value 141 (corresponding to SIGPIPE) is not a solution because it can be a real failure with some utilities. BTW, the association with a signal like SIGPIPE is just a convention; apart from that, 141 is a non-zero status like others (in particular with programs that have not been written for POSIX).
For instance, in any shell:
$ sh -c "echo foo; exit 141" foo $ echo $? 141
while no broken pipe is involved here. How would you differentiate such a failure from a broken pipe?
> I also tested "hg log", it behaves the same way, although interestingly > they cast SIGPIPE to 255 in their exit code.
I get 141, like with git:
$ hg log $ echo $? 141
-- Vincent Lefèvre <vincent@vinc17.net> - Web: <https://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)