I am making a script in bash to configure some MacOS machines that has some brew formulas installed. I first want to check if a specific version of that formula has been installed. If not installed, the script will install it.
The thing is that I cannot figure out how to check this. E.g. brew ls --versions openssl
returns all installed versions. But I want to check for a specific version, kinda similar to gems gem list -i cocoapods -v 1.3.1
. The reason for this is that some projects require to have specific versions installed (like openssl).
Is there a possibility to do this? Note that there are some brew formulas to be checked, so I want to keep it as lightweight as possible :)
I have something in mind like this (but with the correct check of course):
if ! NOT_INSTALLED; then #check to see if ruby -v 2.2.2 has been installed
brew install ruby -v 2.2.2
else
echo "Skipping install ruby..."
fi
Thanks in advance!