У меня есть этот скрипт, который отлично работает на моей машине. Для тестирования скрипта у меня есть виртуальная машина с той же версией ОС, MacOSCatalina. На «реальной машине» скрипт работает просто отлично, но на ВМ всегда есть ошибка:
syntax error in a conditional expression, syntax error near ]]
Вот скрипт:
echo "check if Homebrew needs to be installed"
echo "Homebrew is a package manager for macOS"
sleep 2
which -s brew
if [[ $? != 0 ]]
then
echo "Homebrew is not installed, installing Homebrew now"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "Homebrew is already installed"
fi
sleep 2
echo ""
echo "check if node.js needs to be installed"
echo "node.js is a needed library for angular"
sleep 2
which -s node
if [[ $? != 0 ]]
then
echo "node.js is not installed, installing node.js now"
brew install node
else
echo "node.js is already installed"
fi
sleep 2
echo ""
echo "check if Angular needs to be installed"
echo "Angular as a huge framework serves as the frontend in our project"
sleep 2
which -s ng
if [[ $? != 0 ]]
then
echo "Angular is not installed, installing Angular now"
npm install angular
else
echo "Angular is already installed"
fi
echo ""
echo "Done"