I have rbenv
(ruby version manager) installed on machine and it works like that:
$ rbenv local
2.3.1
Writing to stdout the local version of my ruby. I want to rescue this version and declare it in a variable to reuse in another occasion.
$ declare -r RUBY_DEFINED_VERSION=$(rbenv local)
$ echo Using ruby version $RUBY_DEFINED_VERSION
Using ruby version 2.3.1
It works!
But I don't want to use a subshell to do the work (using $()
or ``
). I want to use the same shell and I don't want to create a tmp file to do the work.
Is there a way to do this?
Note: declare -r
is not mandatory, it can be a simple var=FOOBAR
.
<fifo
" !$(...)
or temporary file?rbenv local
changes some variables and I want to use these variables. The shell script will run on various projects and I can't trust in/tmp
or permissions. Some machines I just can write on/var/tmp
..ruby-version
file in the current directory? BTW, I can not find anything that saysrbenv local
changes anything. It's supposed to only report the local version according to github.com/rbenv/rbenv#rbenv-localrvm
(the shell script will prevent therbenv
andrvm
) some variables are set, likeRUBY_VERSION
. But I think I can usecat .ruby-version
. :-)