How can I parse long-form arguments in shell?
问题 Everything I see uses getopt or the slightly-fancier getopts which only supports one-character options (e.g., -h but not --help ). I want to do fancy long options. 回答1: I've done something like this: _setArgs(){ while [ "${1:-}" != "" ]; do case "$1" in "-c" | "--configFile") shift configFile=$1 ;; "-f" | "--forceUpdate") forceUpdate=true ;; "-r" | "--forceRetry") forceRetry=true ;; esac shift done } As you can see, this supports both the single-character and the longer options nicely. It