Skip to content

Instantly share code, notes, and snippets.

@hauke96
Last active May 12, 2018 16:35
Show Gist options
  • Save hauke96/652570231311625dde48b39034c22f6a to your computer and use it in GitHub Desktop.
Save hauke96/652570231311625dde48b39034c22f6a to your computer and use it in GitHub Desktop.
for (( i=1; i<=$#; i++ ))
do
arg=${@:$i:1} # Gets the string i
val=${@:$i+1:1} # Gets the string i+1
case $arg in
-p)
package=$val
# The parse the next argument and not this value
((i++))
;;
--package=*)
# Split at = char and remove the shortest match from beginning
package=${arg#*=}
;;
-i|--install)
command="install"
;;
*)
echo "Unknown argument number $i: '$arg'"
;;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment