Last active
July 18, 2018 13:32
-
-
Save Chekote/955d6d3e9d0bd8d781aa989675144c99 to your computer and use it in GitHub Desktop.
How to parse arguments passed to a shell script
This file contains hidden or 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_args() { | |
while [[ $# -gt 0 ]]; do | |
case $1 in | |
-b|--branch) branch="$2" ;; | |
-t|--tag) tag="$2" ;; | |
--timeout) timeout="$2" ;; | |
*) break ;; | |
esac | |
shift 2 | |
done | |
rest=("$@") | |
} | |
parse_args "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment