`script.sh: 12: Bad substitution`
IntermediateTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer
Likely causes → A Bash-only parameter expansion run by dash: ${var//a/b}, ${var^^}, ${var:0:3}, ${!name}, ${arr[@]}. Or a typo like ${var-name with space} or $(var) confusion.
Diagnose → Check the shell (ps -p $$ -o comm= inside the script, or the shebang) and line 12.
Fix → Run with Bash, or use POSIX alternatives: $(printf '%s' "$var" | sed 's/a/b/g'), $(printf '%s' "$var" | tr '[:lower:]' '[:upper:]'), ${var%%.*}/${var#*-} (those are POSIX).
Prevent → shellcheck -s sh flags these as SC3060 and friends.
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