Created
August 12, 2019 22:24
-
-
Save telnet2/a625903d4debd56237043a35b3ead122 to your computer and use it in GitHub Desktop.
BASH getopts with mixed positional arguments
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
ARGS=() | |
while [ $# -gt 0 ]; do | |
unset OPTIND | |
unset OPTARG | |
while getopts v options; do | |
case $options in | |
v) VERBOSE=true ;; | |
esac | |
done | |
shift $((OPTIND - 1)) | |
ARGS=("${ARGS[@]}" $1) | |
shift | |
done | |
CMD=${ARGS[0]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment