Skip to content

Instantly share code, notes, and snippets.

@jhurliman
Created August 25, 2015 22:44
Show Gist options
  • Save jhurliman/ef18f8cd1880dc00365d to your computer and use it in GitHub Desktop.
Save jhurliman/ef18f8cd1880dc00365d to your computer and use it in GitHub Desktop.
Parse command line options in pure bash
# Parse command line arguments
while [[ $# > 1 ]]; do
local key="$1"
case $key in
-g|--github-token)
GITHUB_TOKEN="$2"
shift
;;
# Catch-all
*)
;;
esac
shift
done
@ProBackup-nl
Copy link

ProBackup-nl commented Jun 15, 2017

[[ $# -gt 1 ]] works more reliable then [[ $# > 1 ]] in the ash shell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment