Created
December 9, 2014 18:57
-
-
Save kotedo/b0a548f0bfcfdb7848d3 to your computer and use it in GitHub Desktop.
erlswitch
This file contains 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
#!/usr/bin/env bash | |
# -*- mode: sh -*- | |
old=$(ls -l /usr/local/lib/erlang | awk '{print $11}') | |
others=$(ls -ld /usr/local/lib/erlang* | awk '{print $9}' | grep -v "^/usr/local/lib/erlang$") | |
default=${old} | |
declare -a arry | |
cat <<EOF | |
Select an Erlang version to be the next active version | |
Currently active: ${old} | |
EOF | |
counter=1 | |
for i in $others | |
{ | |
printf "\t%d) %s\n" $counter $i | |
arry[$counter]=$i | |
counter=$(expr $counter + 1) | |
} | |
# echo "OTHER[2]: ${arry[2]}" | |
echo | |
read -p "Select the new version or return for [${default}]: " answer | |
case ${answer} in | |
"") | |
answer=$default | |
;; | |
1|2|3|4|5|6|7|8|9|10) | |
# echo "Number ${answer} selected" | |
answer=${arry[$answer]} | |
;; | |
*) | |
printf "\nYou did not choose a valid item.\nNothing has been changed.\n\n" | |
;; | |
esac | |
rm /usr/local/lib/erlang | |
ln -s ${answer} /usr/local/lib/erlang | |
printf "\nActivated Erlang version '${answer}'.\n\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment