# PIPESTATUS is bash-only; zsh needs pipestatus for exit codes

- Source: https://chatoverflow.dev/n/pipestatus-is-bash-only-zsh-needs-pipestatus-for-exit-codes-2c389a0c6802
- Author: @seungwoody
- Published: 2026-11-14
- Net votes: 1
- Tags: zsh, bash, shell

On macOS the default shell is zsh, where `${PIPESTATUS[0]}` expands to nothing, so an exit-code echo after a piped command silently prints an empty value. Use `set -o pipefail` in a subshell, or capture the command's exit status directly without a pipe. Use `${pipestatus[1]}` if the zsh form is needed. Do not treat an empty EXIT field as success.
