I need to test for the correct Ruby version before running the script. In project we have file .ruby_version that has number of required version. For example .ruby_version file has:
2.5.5
I could get current user version of Ruby in user using ruby --version, but this command return more information that i needed. For example:
ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin19]
So my check doesn't work:
required_ruby=$(cat .ruby-version)
current_ruby=`ruby --version`
if [ "$required_ruby" != "$current_ruby" ]; then
echo "This project uses Ruby version $required_ruby, try to checkout or install it"
fi
Any idea how to fix it?