bash "syntax error near unexpected token `('" in CI
The shell hit a ( where its grammar did not expect one. The usual cause in CI is a bash-only construct (an array assignment or a function name() definition) being run under /bin/sh, which on Debian and Ubuntu is dash, not bash.
What this error means
The step fails with "syntax error near unexpected token ('" pointing at an array literal like arr=(a b c)` or a function definition, even though the same script runs on your machine.
deploy.sh: 3: Syntax error: "(" unexpected (expecting "}")Common causes
A bash script executed by dash
The shebang is #!/bin/sh, or CI runs sh script.sh, and /bin/sh is dash. Bash arrays and arr=(...) are not POSIX, so dash rejects the parenthesis.
A stray or unescaped parenthesis
An unquoted ( in a case pattern, a filename, or an echo argument is read as a subshell where the grammar does not allow one.
How to fix it
Run the script with bash explicitly
- Set the shebang to
#!/usr/bin/env bashif the script uses bash features. - In CI, invoke it as
bash script.sh, notsh script.sh. - For GitHub Actions, set
shell: bashso steps do not fall back tosh -e.
#!/usr/bin/env bash
files=(a.txt b.txt c.txt)Or write POSIX-only syntax
If the script must run under /bin/sh, avoid arrays and use a POSIX function definition: name() { ... } without the function keyword.
# POSIX-safe: no arrays, no "function" keyword
greet() {
echo "hi $1"
}How to prevent it
- Match the shebang and the invoking command to the features you use.
- Run shellcheck with the right
# shellcheck shell=directive. - Remember
/bin/shis dash on Debian/Ubuntu runners, not bash.