Q:

If loop in Bash not working

I have been working on an installer in bash:
#!/bin/bash
echo "Are you sure you want to install the program installCMD? [y/n]"
answer="$@"
if [ $answer = "y" ] then
   echo "Installing Program installCMD"
   wget /usr/bin http://www.chronos.site90.net/DEV/installCMD 
else
   echo "Not installing program installCMD."
fi

Every time I run it it reads the error
Are you sure you want to install the program installCMD? [y/n]
installCMDInstaller: line 7: syntax error near unexpected token `else'
installCMDInstaller: line 7: `else'

Any help would be apreciated.
Thanks in advance.

A:

You need to correct the first conditional part:
echo "Are you sure you want to install the program installCMD? [y/n]"
answer="$@"
if [ "$answer" == "y" ]; then
   echo "Installing Program installCMD"
   wget /usr/bin http://www.chronos.site90.net/DEV/installCMD 
else
   echo "Not installing program installCMD."
fi

Note the extra quotes and the semicolon after the test.

