I'm working on a function in a shell script I'm writing that will eventually take in and print out a list of vendor names and aliases (for my work) Here's the function in question:
addvendorandalias ()
{
echo
echo -n 'Would you like to create a new vendor list (y or n)? '
read answer
if [ answer='y' ] then
echo 'Enter the name you would like to give the file: '
read vendorfilename
touch $vendorfilename
fi
echo 'Enter the vendorname: '
read vendorname
}
when I try to run the script get this message:
-bash: vendorlist.txt: line 28: syntax error near unexpected token `fi'
-bash: vendorlist.txt: line 28: `fi'
I cannot for the life of me figure out what I've done wrong. According to the book I have I've constructed the if statement properly.