0
read answer #this will read what the user is typing in and makes a string for it

if [[ -z {answer} ]] 
    then 
        echo "Sorry that is not a valid choice, please select from the above list provided" #this will help pick up if the user just enters a blank option

if [[ $1{answer} ]]
    then 
        echo "this has worked" #no clue if this will work going to try this and see if it works
if [[ $2{answer} ]]
    then 
        echo "this is answer 2"

if [[ $3{answer} ]]
    then
        echo "this is answer 3"

if [[ $4{answer} ]]
    then 
        echo "This is answer 4"

if [[ $Q{answer} ]] 
    then 
        echo "this is the quit button"

else 
    echo "no valid choice has been made"

fi
fi
fi
fi
fi
fi

so i am trying to run this code, i have closing arguments for each if statement, but every time i try and run it it shows "line 51: syntax error: unexpected end of file" the code goes up to line 50, i tried putting in ;; but it ran a syntax error on them, i tried converting with the dos2unix command but nothing, is there something i am missing?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • 2
    Try to pass your code in https://www.shellcheck.net/ – Fravadona May 10 '22 at 11:49
  • 1
    That's not how you reference variables (or compare them) in bash; see ["How to compare strings in Bash"](https://stackoverflow.com/questions/2237080/how-to-compare-strings-in-bash) (though a `case` statement might be better here; see ["Bash script, case statement and sub-menus"](https://stackoverflow.com/questions/4728320/bash-script-case-statement-and-sub-menus)). – Gordon Davisson May 10 '22 at 16:57

1 Answers1

1

Add the $ to this line, like so

if [[ -z ${answer} ]]