Created
August 25, 2015 22:44
-
-
Save jhurliman/ef18f8cd1880dc00365d to your computer and use it in GitHub Desktop.
Parse command line options in pure bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[[ $# -gt 1 ]]
works more reliable then[[ $# > 1 ]]
in the ash shell.