I want to run:
> ruby --version
ruby 1.9.2p0 (2010-08-18 revision 29034) [x86_64-darwin10.4.0]
and then see if 1.9.2
is printed out. If so, i return true
.
How would this method look like using a regexp?
I want to run:
> ruby --version
ruby 1.9.2p0 (2010-08-18 revision 29034) [x86_64-darwin10.4.0]
and then see if 1.9.2
is printed out. If so, i return true
.
How would this method look like using a regexp?
I'd recommend using 'RUBY_VERSION', however you could do something like:
`ruby --version`.include? "1.9.2"
Maybe I am off the track here but you do seem to want to check the version from the shell ? Something like this then will do it.
export VERSION=`ruby --version | grep 1.9.2`
if [[ -n "$VERSION" ]] ; then
echo "you have the right version yay!"
else
echo "bummer dude ><!"
fi