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

`warning: here-document at line 12 delimited by end-of-file (wanted `EOF')` and the rest of the script never runs.

BeginnerTroubleshootingTroubleshooting: syntax, parsing and interpreter errors
Answer

Likely causes → Bash never found the closing EOF line, so it treated the rest of the file as here-doc content. The delimiter is indented with spaces, has trailing whitespace or a \r, or is spelled differently.

Diagnose →

grep -n 'EOF' script.sh | cat -A     # look for "  EOF$" or "EOF $" or "EOF^M$"

Fix → Put the delimiter alone at column 1 with nothing after it. If you want indentation, use <<-EOF and indent with tabs only.

Prevent → shfmt and ShellCheck flag broken here-docs; configure the editor to show whitespace.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Troubleshooting: syntax, parsing and interpreter errors