title: How to make bash script fail at the end when an error occurs in a pipe
body: <p>For now I'm using this in my script:</p>
  
  <pre><code>set -euxo pipefail
  </code></pre>
  
  <p>This will make my bash script fail immediatly if there is an error in my pipe.
  When I leave this option my script will run fully and end with exit 0 (no error).</p>
  
  <p>I want to have a mix of both. I want to end the whole script but have <code>exit 1</code>; at the end if there was an error in a pipe.</p>
  
  <p>My script looks like this:</p>
  
  <pre><code>#!/bin/bash
  set -euxo pipefail
  curl --fail --compressed -u "$CREDS" -X GET --header 'Accept: xxx' --header 'Accept-Language: de-DE' 'https://api/call1' | jq -S "." &gt; "output1.json"
  curl --fail --compressed -u "$CREDS" -X GET --header 'Accept: xxx' --header 'Accept-Language: de-DE' 'https://api/call2' | jq -S "." &gt; "output2.json"
  cat output1.json
  cat output2.json
  </code></pre>
  
  <p>So I don't want to exit the script if <code>call1</code> fails. If <code>call1</code> fails I want to go to <code>call2</code> and the <code>cat</code> commands before exiting the script with <code>exit code 1</code>.</p>