diff options
author | Mattias Andrée <maandree@operamail.com> | 2013-08-18 13:05:32 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2013-08-18 13:05:32 +0200 |
commit | f8a5ac5337702119cb0f285879953cbdeceaeb20 (patch) | |
tree | 9e3d868dac98450e90ca8afd689424f26de603dd /src/argparser.bash | |
parent | forgot to update the version (diff) | |
download | argparser-f8a5ac5337702119cb0f285879953cbdeceaeb20.tar.gz argparser-f8a5ac5337702119cb0f285879953cbdeceaeb20.tar.bz2 argparser-f8a5ac5337702119cb0f285879953cbdeceaeb20.tar.xz |
add alternative mode
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/argparser.bash')
-rw-r--r-- | src/argparser.bash | 4 |
1 files changed, 3 insertions, 1 deletions
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 |