Skip to content
Advertisement

Bash Syntax Error syntax error: unexpected end of file

We are using the Bourne-Again Shell.

What does this error mean?:

syntax error: unexpected end of file

PS3="Press 1, 2, 3, 4 to do the thing they say next to them."
options=("Option 1" "Option 2" "Option 3" "Quit")
select opt in "${options[@]}"
do
    case $opt in
        "start game")
            echo ok
            ;;
        "level select")
            echo "no"
            ;;
        "how do i exit")
            echo "click the window to close"
        xkill
            ;;
        "exit")
            echo wwaaaatttt
        echo click the window to kill it.
            xkill
            echo "if your reading this, you must have opened
            echo "a game file. you've bricked the exit
            echo button. great job.
            ;;
        *) echo not a thing, sorry;;
    esac
done

Advertisement

Answer

The single quoted string starting with

ve bricked the

is missing the closing single quote. SO’s syntax highlighting shows it, too.

Maybe you wanted to backslash the quote?

echo "a game file. you've bricked the exit

or there are double quotes missing too?

echo "if you're reading this, you must have opened"
echo "a game file. you've bricked the exit"
echo "button. great job."

In such a case, you can also use a HERE-doc:

cat << 'EOF'
if you're reading this, you must have opened
a game file. you've bricked the exit
button. great job.
EOF
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement