Interview Prep/Shell Scripting/Troubleshooting: syntax, parsing and interpreter errors

A script that uses `done < <(kubectl get pods -o name)` fails with `Syntax error: redirection unexpected` in CI but works locally.

IntermediateTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer

Likely causes → The CI step runs the script with sh (dash or BusyBox ash), which does not support process substitution. Common in GitLab CI script: blocks on Alpine images, or sh ./script.sh in a Makefile.

Diagnose → Print the shell in the job: echo "$0"; readlink -f /proc/$$/exe.

Fix → Invoke with Bash (bash ./script.sh, install bash in Alpine images with apk add --no-cache bash), or replace the construct: kubectl get pods -o name > "$tmp"; while ...; done &lt; "$tmp".

Prevent → Pin the interpreter via shebang and execute scripts directly, never through sh.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: syntax, parsing and interpreter errors