=Start=
搜索关键字:
linux how to get all pipe return value
参考链接:
- http://unix.stackexchange.com/questions/14270/get-exit-status-of-process-thats-piped-to-another
- http://stackoverflow.com/questions/6871859/piping-command-output-to-tee-but-also-save-exit-code-of-command
- http://tldp.org/LDP/abs/html/internalvariables.html#PIPESTATUSREF
参考解答:
$PIPESTATUS 数组(在Zsh中是小写)
# Bash $ false | true $ echo "${PIPESTATUS[0]} ${PIPESTATUS[1]}" 1 0 # Zsh $ false | true $ echo "${pipestatus[1]} ${pipestatus[2]}" 1 0
# Zsh $ echo $0 -zsh $ echo $ZSH_VERSION 5.0.5 $ ls | bogus_command | wc zsh: command not found: bogus_command 0 0 0 $ echo ${pipestatus[@]} 0 127 0
=EOF=