-1

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
choroba
  • 231,213
  • 25
  • 204
  • 289
  • What are you trying to do when you get that error? Running a script? Processing a file? Any languages being used specifically? Any more detail to the error? – Theyna Jul 10 '17 at 21:58
  • 1
    Hello and welcome to StackOverflow. Please take some time to read the help page, especially the sections named ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic) and ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask). And more importantly, please read [the Stack Overflow question checklist](http://meta.stackexchange.com/q/156810/204922). You might also want to learn about [Minimal, Complete, and Verifiable Examples](http://stackoverflow.com/help/mcve). – jmunsch Jul 10 '17 at 21:58
  • also see: https://stackoverflow.com/questions/6366530/bash-syntax-error-unexpected-end-of-file – jmunsch Jul 10 '17 at 22:00
  • Making a main menu – The Derpiest Coder Jul 10 '17 at 22:01
  • You might have an unckosed (double) quote, cintrol flow or unmatched (curly) brace. – Walter A Jul 10 '17 at 22:02
  • @TheDerpiestCoder using pure bash commands? Is it web based? Mobile based(android/apple)? Application based? What exactly is going on in the code where you are getting the error? – Theyna Jul 10 '17 at 22:02
  • i'm gonna add the code to the post real quick – The Derpiest Coder Jul 10 '17 at 22:03
  • @Theyna it's just terminal based – The Derpiest Coder Jul 10 '17 at 22:04
  • @TheDerpiestCoder https://meta.stackexchange.com/questions/21788/how-does-editing-work – jmunsch Jul 10 '17 at 22:04
  • @Theyna I'm just echo-ing things and/or running XKill – The Derpiest Coder Jul 10 '17 at 22:07
  • i just felt bad about commenting this – The Derpiest Coder Jul 10 '17 at 22:07
  • The error is: line 25: unexpected EOF while looking for matching `'' line 31: syntax error: unexpected end of file – The Derpiest Coder Jul 10 '17 at 22:10

2 Answers2

2

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
choroba
  • 231,213
  • 25
  • 204
  • 289
1

ShellCheck is helpful:

Line 20:
            echo "if your reading this, you must have opened
                 ^-- SC1078: Did you forget to close this double quoted string?

And indeed you did. Also on the next line.

Here's the script without syntax errors (but you still have to fix the options to access them):

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" # HERE
            echo "a game file. you've bricked the exit"       # HERE
            echo button. great job.
            ;;
        *) echo not a thing, sorry;;
    esac
done
that other guy
  • 116,971
  • 11
  • 170
  • 194