Under `sh`, the script fails with `Syntax error: "(" unexpected`.
IntermediateTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer
Likely causes → Bash-only syntax parsed by dash: an array assignment hosts=(a b c), function name() {, or <(...) process substitution (which gives Syntax error: redirection unexpected instead).
Diagnose → shellcheck -s sh script.sh lists each bashism with the line number; checkbashisms script.sh does the same.
Fix → Run it with Bash (fix the shebang or invocation), or port: arrays to set -- a b c or newline-separated strings, function f() to f(), process substitution to a temp file.
Prevent → Decide per script: Bash with an explicit shebang, or POSIX sh checked with shellcheck -s sh.
More on Troubleshooting: syntax, parsing and interpreter errors
`./deploy.sh` fails with `bash: ./deploy.sh: /bin/bash^M: bad interpreter: No such file or directory` (or, on Bash 5.2, `cannot execute: required file not found`).Beginner`bash: ./backup.sh: Permission denied` right after cloning the repo.Beginner`deploy.sh: line 14: syntax error near unexpected token `fi'`Beginner`install.sh: line 87: syntax error: unexpected end of file`Beginner`warning: here-document at line 12 delimited by end-of-file (wanted `EOF')` and the rest of the script never runs.Beginner`bash: [: missing `]'`Beginner