Skip to content

Instantly share code, notes, and snippets.

@Zeebrow
Created December 17, 2022 20:30
Show Gist options
  • Save Zeebrow/180ed33a0162e7a6f83e3e19419c33e1 to your computer and use it in GitHub Desktop.
Save Zeebrow/180ed33a0162e7a6f83e3e19419c33e1 to your computer and use it in GitHub Desktop.
A good start to working around the limitations of bash's getopt
#!/bin/bash
function _template(){
local OPTION1
local OPTION2
while [ "$#" -gt 0 ]; do
case "$1" in
-o1|--option1) echo o1; OPTION1='true' ;;
-o2|--option2) echo o2; OPTION2='true' ;;
-h|--help) echo "listem get all instances tagged with '${QH_APP_TAG}'
[-r|--running] show only running instances (for debugging)
[-h|--help] show this dialog and exit
"; exit;;
*) ;;
esac
shift
done
echo "option1: $OPTION1"
echo "option2: $OPTION2"
}
case "$1" in
t|template) shift; _template "$@";;
*) echo '
usage:
t|template do template
help show this dialog and exit
';;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment