Skip to content

Instantly share code, notes, and snippets.

@ykai55
Last active March 21, 2019 07:11
Show Gist options
  • Select an option

  • Save ykai55/4d50bbcefd3e1376c250d335f173b436 to your computer and use it in GitHub Desktop.

Select an option

Save ykai55/4d50bbcefd3e1376c250d335f173b436 to your computer and use it in GitHub Desktop.
shell script arguments parsing
want_touch_pinch=1
want_debug=0
want_temp_profile=0
want_verbose=0
while [ $# -gt 0 ]; do
  case "$1" in
    -h | --help | -help )
      usage
      exit 0 ;;
    --verbose )
      want_verbose=1
      shift ;;
    -g | --debug )
      want_debug=1
      shift ;;
    --no-touch-pinch )
      want_touch_pinch=0
      shift ;;
    --temp-profile )
      want_temp_profile=1
      shift ;;
    -- ) # Stop option prcessing
      shift
      break ;;
    * )
      break ;;
  esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment