bash - Install Latest Stable Version of Ruby Using rbenv -


i want install latest stable version of ruby available rbenv. feature won't happening in rbenv itself.

when run command rbenv install -l in shell, long list of available versions. list has types of entries. following partial list demonstrate format , diversity:

$ rbenv install -l available versions:   2.0.0-p643   2.0.0-p645   2.1.0-dev   2.1.0-preview1   2.1.0-preview2   2.1.0-rc1   2.1.4   2.1.5   2.1.6   2.2.0-dev   2.2.0-preview1   2.2.0-preview2   2.2.0-rc1   2.2.0   2.2.1   2.2.2   2.3.0-dev   jruby-1.7.19   jruby-1.7.20   jruby-9.0.0.0-dev   jruby-9.0.0.0+graal-dev   jruby-9.0.0.0.pre1   jruby-9.0.0.0.pre2   maglev-1.0.0   maglev-1.1.0-dev   maglev-2.0.0-dev   mruby-dev   mruby-1.0.0   mruby-1.1.0   rbx-2.5.2   rbx-2.5.3   ree-1.8.7-2011.12   ree-1.8.7-2012.01   ree-1.8.7-2012.02   topaz-dev 

my goal automate command rbenv install version in shell script version highest x.x.x release. in other words, need automatically substitute highest entry on list starts number , not end -something version. list, need 2.2.2.

what can put in shell script automatically pick highest x.x.x version in command rbenv install x.x.x?

edit: since ruby not yet installed, solution has in bash , not ruby.

edit 2: want mri (mainstream) version of ruby.

rbenv install -l | awk -f '.' '    /^[[:space:]]*[0-9]+\.[0-9]+\.[0-9]+[[:space:]]*$/ {       if ( ($1 * 100 + $2) * 100 + $3 > max ) {           max = ($1 * 100 + $2) * 100 + $3          version=$0          }       }    end { print version }' 
  • take biggest version (sorted order or not)

if list sorted simpler sed (posix version) enough

rbenv install -l | sed -n '/^[[:space:]]*[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}[[:space:]]*$/ h;${g;p;}' 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -