So I am trying to write a bash script that states:
if file a exists, and directory b exists, run composer install, check for the vendor folder. if we found it - echo something out and exit.
But it keeps saying:
./composerrun.sh: line 6: syntax error near unexpected token `fi'
./composerrun.sh: line 6: ` fi'
And I am too new to bash to understand how this closing "brace" is wrong:
#!/bin/bash
if checkForComposerJson && checkForAisisCore
composer install
if checkForVendor
echo "Found vendor"; exit;
fi
fi
function checkForAisisCore {
if [-d "AisisCore/"]
then
return 0;
else
echo "would you like us to create the directory?" yn,
case $yn in
Yes )
mkdir "AisisCore/";
if [-d "AisisCore/"]
return 0;;
else
echo "We could not create the directory as you requested";
return 1;;
end
No ) return 1;;
* ) echo "Please put in either yes or no";
esac
fi
}
function checkForVendor(){
if [-d "vender/adam.balan/aisis-core/"]
return 0;
else
"Something is wrong. We could not find the vendor/ folder. Please check that you are running this script inside of your theme or project folder.";
return 1;
fi
}
function checkForComposerJson(){
if [-f "composer.json"]
return 0;
else
echo "You need composer.json with appropriate information about AisisCore";
return 1;
fi
}
Also, my mkdir, where I make the directory if it doesn't exist - the check I do after words - is it worth it?
You forgot a
then
. It should be: