`install.sh: line 87: syntax error: unexpected end of file`
BeginnerTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer
Likely causes → Something opened was never closed: an if without fi, a loop without done, a case without esac, a { without }, an unterminated quote, or a here-doc whose closing delimiter is indented or has trailing spaces.
Diagnose →
bash -n install.sh
grep -nE '^\s*(if|fi|for|while|until|done|case|esac)\b' install.sh # count pairs by eye
grep -n "EOF" install.sh | cat -A | head # trailing spaces show as "EOF $"
Fix → Add the missing terminator or fix the quote. The reported line is the end of the file, not the error location, so bisect by commenting out blocks if the file is large.
Prevent → Keep functions short, use shfmt (it refuses to format unbalanced code), and lint in CI.
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`warning: here-document at line 12 delimited by end-of-file (wanted `EOF')` and the rest of the script never runs.Beginner`bash: [: missing `]'`BeginnerA script prints `/bin/sh: 1: [[: not found` and then continues as if the test were false.Beginner