From f8a5ac5337702119cb0f285879953cbdeceaeb20 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 18 Aug 2013 13:05:32 +0200 Subject: add alternative mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/argparser.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/argparser.bash') diff --git a/src/argparser.bash b/src/argparser.bash index 3144f01..d8dc967 100644 --- a/src/argparser.bash +++ b/src/argparser.bash @@ -44,6 +44,7 @@ args_VARIADIC=2 # @param $3:str Long, multi-line, description of the program, empty for none # @param $4:str The name of the program, empty for automatic # @param $5:str Output channel, by fd +# @param $6:int Set to 1 to use single dash/plus for long options function args_init { test "$TERM" = linux @@ -67,6 +68,7 @@ function args_init fi args_out="$(realpath "/proc/$$/fd/${args_out}")" args_files=() + args_alternative="$6" } @@ -494,7 +496,7 @@ function args_parse elif [ "$arg" = "--" ]; then dashed=1 elif (( ${#arg} > 1 )) && [ "${_arg::1}" = "-" ]; then - if (( ${#arg} > 2 )) && [ "${arg::1}" = "${arg:1:1}" ]; then + if [ "${args_alternative}" = 1 ] || (( ${#arg} > 2 )) && [ "${arg::1}" = "${arg:1:1}" ]; then if [ ! $dontget = 0 ]; then (( dontget-- )) elif [ ! -e "${args_optmap}/${arg}" ]; then -- cgit v1.2.3-70-g09d2