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

`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.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: syntax, parsing and interpreter errors