Skip to content

Commit 2e5af9f

Browse files
author
Damien Nadé
committed
argsparse-completion.sh: __argsparse_complete_value: fixed docstring and fixed short option case handling
1 parent 75f37b9 commit 2e5af9f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

argsparse-completion.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ __argsparse_complete_value() {
148148
## matching long option name. Also if "$cur" should be this option
149149
## value, then return 0.
150150
## @param word any word.
151+
## @param long... a list of long options.
151152
## @return the long option matching given parameter.
152153
## @retval 0 if given word matches an option and if that option
153154
## accepts a value.
@@ -159,12 +160,9 @@ __argsparse_complete_get_long() {
159160
shift
160161
local -a longs=( "$@" )
161162
local long
162-
if [[ $word = -+([!-]) ]] && \
163-
long=$(argsparse_short_to_long "${word:1:1}") # XXX: change this
163+
if [[ $word = -[!-] ]]
164164
then
165-
# -<char><something>, char being a recognized short option
166-
# which is wrong.
167-
long=$long
165+
long=$(argsparse_short_to_long "${word#-}") || return
168166
elif __argsparse_index_of "$word" "${longs[@]}" >/dev/null
169167
then
170168
long=${word#--}

0 commit comments

Comments
 (0)