diff options
-rwxr-xr-x | mbuto | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -456,8 +456,8 @@ list_join() { ### Suboption Parsing ######################################################### SUBOPTS=' - kselftests C collection Select a collection of kernel tests - kselftests T test Select a test from a collection + kselftests C collection 2 Select a collection of kernel tests + kselftests T test 2 Select a test from a collection ' subopts_profile= @@ -469,7 +469,7 @@ subopts_profile= subopts_usage_one() { __profile="${1}" __short="${2}" - __help="${4}" + __help="${5}" if [ "${usage_subopts_profile}" != ${__profile} ]; then usage_subopts_profile="${__profile}" @@ -511,21 +511,24 @@ subopts_get_one() { eval $(echo SUBOPT_${__name}=\"${__value}\") } -# subopts_get() - Set sub-option values, validating against SUBOPTS +# subopts_get() - Parse sub-options, validating against SUBOPTS # $1: Short option name as passed on command line # $2: Value passed on command line -# Return: 0 on success, 1 if option doesn't match known ones +# Return: argument count including option switch, doesn't return on failure subopts_get() { IFS=' ' for __line in ${SUBOPTS}; do IFS=' ' - subopts_get_one "${1}" "${2}" ${__line} && unset IFS && return 0 + if subopts_get_one "${1}" "${2}" ${__line}; then + unset IFS + return $(echo "${__line}" | "${AWK}" '{print $4}') + fi + IFS=' ' done - unset IFS - return 1 + usage } ### CPIO ####################################################################### @@ -1213,8 +1216,9 @@ while getopts :c:df:k:m:p:s:vh __opt; do v) VERBOSE="y" ;; ?) eval arg=\${$((OPTIND))} - OPTIND=$((OPTIND + 1)) - subopts_get "${OPTARG}" "${arg}" || usage ;; + subopts_get "${OPTARG}" "${arg}" || __subopt_args=$? + OPTIND=$((OPTIND + ${__subopt_args} - 1)) + ;; h|*) usage ;; esac done |