0

I'm using set -o pipefail in my scripts as usual. That works perfectly well and as documented for something like

curl ... | jq ... | psql ...

However, is there a way to determine which command along a pipeline actually failed the whole thing?

I'm looking into this for the sole purpose of more concise logging but couldn't find any documentation thereon.

jenszo
  • 3

1 Answers1

0

Use the PIPESTATUS builtin array:

true | true | false | true | true
declare -p PIPESTATUS
declare -a PIPESTATUS=([0]="0" [1]="0" [2]="1" [3]="0" [4]="0")
glenn jackman
  • 85,964