Home > Enterprise >  I believe my code is formatted correctly but still getting `syntax error near unexpected token '
I believe my code is formatted correctly but still getting `syntax error near unexpected token '

Time:11-29

I am trying to make a menu for a BASH app, and getting an error with 'fi'

This is the code:

chmod u x main.sh

menu() {
  clear
  echo 1. Option A
  echo 2. Option B
  read input
if [ $input == "1" ] ;
  then
  a()
  fi
if [ $input == "2" ] ;
  then
  b()
  fi
}

a(){
#code
}

b(){
#code
}

menu

I have made sure I put spaces around brackets, then on a new line, and added semicolons I really don't know why this it's doing this, any help would be greatly appreciated.

CodePudding user response:

In bash, the function call syntax doesn't use the parentheses:

a  # not a()!
  • Related