Last active
January 2, 2016 04:28
-
-
Save mpapis/8250353 to your computer and use it in GitHub Desktop.
ruby vs shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "2.10.3".split(".")[0..1].join(".") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [[ -n "${ZSH_VERSION:-}" ]] | |
then __array_start=1 | |
else __array_start=0 | |
fi | |
__rvm_take_n() | |
{ | |
typeset IFS __temp_counter | |
typeset -a __temp_arr1 __temp_arr2 | |
IFS=$3 | |
if [[ -n "${ZSH_VERSION:-}" ]] | |
then eval "__temp_arr1=( \${=$1} )" | |
else eval "__temp_arr1=( \$$1 )" | |
fi | |
__temp_counter=0 | |
__temp_arr2=() | |
while (( __temp_counter < $2 )) | |
do __temp_arr2+=( "${__temp_arr1[__array_start+__temp_counter++]}" ) | |
done | |
eval "$1=\"\${__temp_arr2[*]}\"" | |
} | |
var1=2.10.3 | |
__rvm_take_n var1 2 . | |
echo $var1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment