Pressing Ctrl+C during `while read -r host; do ssh -n "$host" uptime; done < hosts.txt` only skips to the next host. You have to press it 40 times.
IntermediateTroubleshootingTroubleshooting: strict mode, exit codes, pipelines and traps
Answer
Likely causes → SIGINT goes to the foreground process group. ssh handles it and exits with its own status (255) rather than dying from the signal, so Bash concludes the child handled Ctrl+C and the loop simply continues.
Diagnose → Check $? after the interrupted ssh (255 or 130 instead of the shell itself exiting). trap -p INT shows no trap is set.
Fix → Trap INT and TERM in the script so it stops itself:
trap 'echo "interrupted" >&2; exit 130' INT
trap 'echo "terminated" >&2; exit 143' TERM
while read -r host; do
ssh -n -o ConnectTimeout=5 "$host" uptime || echo "$host: failed ($?)" >&2
done < hosts.txt
Prevent → Every long-running loop script gets INT/TERM traps that exit with 128+signal and let the EXIT trap clean up.
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.BeginnerOn a CentOS 7 / Amazon Linux 2 host, `deploy.sh "${extra_args[@]}"` fails with `extra_args[@]: unbound variable`. It works on your laptop.Advanced`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.Advanced