From 15213e550b15d8f68153c98b20d6c90bebef9361 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 26 Aug 2013 14:12:52 +0200 Subject: fix bash version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/argparser.bash | 59 +++++++++++++++++++++++++++++------------------------- 1 file changed, 32 insertions(+), 27 deletions(-) (limited to 'src/argparser.bash') diff --git a/src/argparser.bash b/src/argparser.bash index 2cf062f..75a2f59 100644 --- a/src/argparser.bash +++ b/src/argparser.bash @@ -634,13 +634,7 @@ function args_parse if [ "${args_alternative}" = 1 ] || (( ${#arg} > 2 )) && [ "${arg::1}" = "${arg:1:1}" ]; then if [ ! $dontget = 0 ]; then (( dontget-- )) - elif [ ! -e "${args_optmap}/${arg}" ]; then - (( args_unrecognised_count++ )) - if (( args_unrecognised_count <= 5 )); then - echo "${args_program}: warning: unrecognised option ${arg}" >> "${args_out}" - fi - rc=1 - else + elif [ -e "${args_optmap}/${arg}" ]; then std="$(head -n 1 < "${args_optmap}/${arg}")" type="$(head -n 2 < "${args_optmap}/${arg}" | tail -n 1)" trigger="$(tail -n 1 < "${args_optmap}/${arg}")" @@ -649,26 +643,6 @@ function args_parse argqueue+=( "" ) nulqueue+=( 1 ) "$trigger" "${arg}" "${std}" - elif [ ! "${arg/=/}" = "${arg}" ]; then - _arg="${arg%%=*}" - type="$(head -n 1 < "${args_optmap}/${_arg}" | tail -n 1)" - if (( $type >= ${args_ARGUMENTED} )); then - optqueue+=( "${_arg}" ) - argqueue+=( "${arg#*=}" ) - nulqueue+=( 0 ) - if [ $type = ${args_VARIADIC} ]; then - dashed=1 - "$trigger" "${arg}" "${std}" - else - "$trigger" "${arg}" "${std}" "${arg#*=}" - fi - else - (( args_unrecognised_count++ )) - if (( args_unrecognised_count <= 5 )); then - echo "${args_program}: warning: unrecognised option ${arg}" >> "${args_out}" - fi - rc=1 - fi elif (( $type <= ${args_OPTARGUMENTED} )); then optqueue+=( "${arg}" ) (( get++ )) @@ -678,6 +652,37 @@ function args_parse nulqueue+=( 1 ) dashed=1 fi + elif [ ! "${arg/=/}" = "${arg}" ]; then + type=x + _arg="${arg%%=*}" + if [ -e "${args_optmap}/${_arg}" ]; then + type="$(head -n 2 < "${args_optmap}/${_arg}" | tail -n 1)" + fi + if [ ! $type = x ] && (( $type >= ${args_ARGUMENTED} )); then + optqueue+=( "${_arg}" ) + argqueue+=( "${arg#*=}" ) + nulqueue+=( 0 ) + std="$(head -n 1 < "${args_optmap}/${_arg}")" + trigger="$(tail -n 1 < "${args_optmap}/${_arg}")" + if [ $type = ${args_VARIADIC} ]; then + dashed=1 + "$trigger" "${_arg}" "${std}" + else + "$trigger" "${_arg}" "${std}" "${arg#*=}" + fi + else + (( args_unrecognised_count++ )) + if (( args_unrecognised_count <= 5 )); then + echo "${args_program}: warning: unrecognised option ${_arg}" >> "${args_out}" + fi + rc=1 + fi + else + (( args_unrecognised_count++ )) + if (( args_unrecognised_count <= 5 )); then + echo "${args_program}: warning: unrecognised option ${arg}" >> "${args_out}" + fi + rc=1 fi else sign="${_arg::1}" -- cgit v1.2.3-70-g09d2