I want to build a shell script that accepts multiple optional parameters. However, I'm somehow stuck when getting the parameters. I want the script to be called in multiple ways
scriptname test -gm git@remote.com
This would create a folder test, init a git and add the remote with the given URL
scriptname test -gm git@remote.com -ig
This would do the same as above but also install grunt/a gruntfile for the user
scriptname test -ig
This would create a folder test, and install grunt without doing anything with git
However, it seems like only my -gm parameter is used in the script
while [[ $# > 2 ]]
do
key="$2"
case $key in
-gm|--gitremote)
GITREMOTE="$3"
shift
;;
-ig|--installgrunt)
echo 'test'
shift
;;
*)
# unknown option
;;
esac
shift
done
Test never gets outputted. Does it have something to do with key=$2"
? I don't really know how to have optional multiple parameters