| 13 | | echo |
| 14 | | echo "Welcome to scripts.mit.edu. Which service would you like to use?" |
| 15 | | echo |
| 16 | | choices | sed 's/^[^ ]* //' | cat -n |
| 17 | | echo |
| 18 | | printf "Please enter a number 1-%d: " "$nchoices" |
| 19 | | read num |
| 20 | | echo |
| | 14 | nchoices=`choices | wc -l` |
| | 15 | |
| | 16 | echo |
| | 17 | echo "Welcome to scripts.mit.edu. Which service would you like to use?" |
| | 18 | echo |
| | 19 | choices | sed 's/^[^ ]* //' | cat -n |
| | 20 | echo |
| | 21 | printf "Please enter a number 1-%d: " "$nchoices" |
| | 22 | read num |
| | 23 | echo |
| | 24 | ;; |
| | 25 | |
| | 26 | 1) |
| | 27 | OIFS="$IFS" |
| | 28 | found=0 |
| | 29 | IFS=' |
| | 30 | ' |
| | 31 | |
| | 32 | for choice in `choices`; do |
| | 33 | possibleChoice=`echo "$choice"|awk -F'[- ]' '{ print "-"$2 }'` |
| | 34 | if [ "$possibleChoice" = "$1" -o "-$possibleChoice" = "$1" ]; then |
| | 35 | num=`choices|grep -n '\'"$possibleChoice"|awk -F: '{ print $1 }'` |
| | 36 | found=1 |
| | 37 | break |
| | 38 | fi |
| | 39 | done |
| | 40 | IFS="$OIFS" |
| | 41 | if [ $found -eq 0 ]; then |
| | 42 | echo "Invalid use of the scripts autoinstaller. Usage: athrun scripts scripts [OPTIONS]" |
| | 43 | exit 1 |
| | 44 | fi |
| | 45 | ;; |
| | 46 | *) |
| | 47 | echo "Invalid use of the scripts autoinstaller. Usage: athrun scripts scripts [OPTIONS]" |
| | 48 | exit 1 |
| | 49 | ;; |
| | 50 | esac |