Skip to content

Instantly share code, notes, and snippets.

@mpapis
Last active January 2, 2016 04:28
Show Gist options
  • Save mpapis/8250353 to your computer and use it in GitHub Desktop.
Save mpapis/8250353 to your computer and use it in GitHub Desktop.
ruby vs shell
puts "2.10.3".split(".")[0..1].join(".")
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