The whole script (starting with `set -o pipefail`) needs to be run in one shell. In this way `set -o pipefail` is only good in the shell that is invoked by `/bin/bash`, which exits before running `curl`.