[Bug 224270] Get exit status of process that's piped to another: set -o pipefail is missing for /bin/sh

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Feb 4 21:16:43 UTC 2018


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=224270

--- Comment #7 from Jilles Tjoelker <jilles at FreeBSD.org> ---
There is a reusable piece of code in a StackOverflow answer
https://unix.stackexchange.com/questions/76162/how-do-i-capture-the-return-status-and-use-tee-at-the-same-time-in-korn-shell/76171#76171

This supports simple commands not containing words "|". By defining a function
containing the command, any command can be used. It is not the most beautiful
option but it will work and isolate the file descriptor manipulation.

It will not help if you want to set -eo pipefail to make shell "do what I mean"
but I think shell will not do proper error handling automatically with any
option setting anyway.

I already committed a small refactoring in support of -o pipefail to sh which
seems good anyway but I'm not entirely sure yet whether to add this feature.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list