Follow

PROMPT_COMMAND="echo pipe statuses: \${PIPESTATUS[@]}" # In bash, this will show the return status of each command in the pipeline in the previous pipeline. So for instance 'ls | grep unmatchingexpression | wc -l' might return '0 1 0' showing that the grep didn't match.

@climagic and 'set -o pipefail' in the beginning of a script will lead to failing commands before a pipe also lead to a failure of the whole command. Otherwise 'cat notAFile | grep PATTERN' won't fail and the script might continue unintended.

Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!