I have this in a github workflow
- run: bash --version
- name: run postgres
run: |
set -e
shopt -s inherit_errexit
export ID=$(docker run \
--publish 5432:5432 \
--network skynet \
--network-alias db.host \
--env-file .github/env/postgres \
--detach ${{ steps.postgres-tag.outputs.data }} )
shell: bash -euET -o pipefail -O inherit_errexit {0}
this is its run output
GNU bash, version 4.4.20(1)-release (x86_64-pc-linux-gnu)
set -e
shopt -s inherit_errexit
export ID=$(docker run \
--publish 5432:5432 \
--network skynet \
--network-alias db.host \
--env-file .github/env/postgres \
--detach )
shell: /bin/bash -euET -o pipefail -O inherit_errexit {0}
env:
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
AWS_ACCESS_KEY_ID: ***
AWS_SECRET_ACCESS_KEY: ***
"docker run" requires at least 1 argument.
See 'docker run --help'.
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
minimal reproduction on OS X with bash 5
bash-5.0$ export ID=$(docker run)
"docker run" requires at least 1 argument.
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
bash-5.0$ echo $?
0
bash-5.0$ docker run
"docker run" requires at least 1 argument.
See 'docker run --help'.
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command in a new container
> echo $? # services -> feature/RS2-1228-optimize-build $ ! RC=1
1
However, the shell is not exiting with an error. I understand that normally a subshell with $()
will not cause an error to happen... but I thought that setting shopt -s inherit_errexit
fixed that. Am I missing something in my code?