On a CentOS 7 / Amazon Linux 2 host, `deploy.sh "${extra_args[@]}"` fails with `extra_args[@]: unbound variable`. It works on your laptop.
AdvancedTroubleshootingTroubleshooting: strict mode, exit codes, pipelines and traps
Answer
Likely causes → Before Bash 4.4, set -u treated expanding an empty array ("${arr[@]}") as an unbound-variable error. CentOS 7 ships Bash 4.2, Amazon Linux 2 ships 4.2; your laptop has 5.x, where empty arrays are fine.
Diagnose →
bash --version | head -1
bash -c 'set -u; a=(); echo "${a[@]}"; echo ok' # fails on 4.2/4.3, prints ok on 4.4+
Fix → Use the ${arr[@]+...} idiom, which expands to nothing when the array is empty and works on every version:
deploy.sh ${extra_args[@]+"${extra_args[@]}"}
Prevent → Know the oldest Bash you support and run CI in that image (for example amazonlinux:2). Document the minimum version at the top of the script and check BASH_VERSINFO if it matters.
More on Troubleshooting: strict mode, exit codes, pipelines and traps
A script with `set -e` stops silently right after `((retries++))` on its first pass. No error message, exit code 1.Intermediate`notify.sh: line 9: SLACK_WEBHOOK: unbound variable` — but the webhook is meant to be optional.Beginner`local release=$(curl -fsS "$API/latest")` fails with a 503, yet the function happily continues and deploys an empty release name.IntermediateA check `procs=$(ps aux | grep -v grep | grep -c '[n]ginx: worker')` kills the script under `set -euo pipefail` whenever nginx is down, before the alert code runs.IntermediateA script that does `first=$(sort -u huge.txt | head -n 1)` exits with status 141 under `pipefail`, but only on large inputs.AdvancedYou added `trap 'echo "failed at line $LINENO" >&2' ERR`, but when a command inside a function fails, nothing is printed and the script just exits.Intermediate