Skip to content

Commit e566395

Browse files
authored
Fix custom completion args for bash (#320)
1 parent 615c946 commit e566395

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Sources/ArgumentParser/Completions/BashCompletionsGenerator.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ struct BashCompletionsGenerator {
149149
?? arg.help.keys.first?.rawValue ?? "---"
150150

151151
return """
152-
$(\(commandName) ---completion \(subcommandNames) -- \(argumentName) "$COMP_WORDS")
152+
$(\(commandName) ---completion \(subcommandNames) -- \(argumentName) "${COMP_WORDS[@]}")
153153
"""
154154
}
155155
}
@@ -207,7 +207,7 @@ extension ArgumentDefinition {
207207
case .custom:
208208
// Generate a call back into the command to retrieve a completions list
209209
let commandName = commands.first!._commandName
210-
return #"COMPREPLY=( $(compgen -W "$(\#(commandName) \#(customCompletionCall(commands)) "$COMP_WORDS")" -- "$cur") )"#
210+
return #"COMPREPLY=( $(compgen -W "$(\#(commandName) \#(customCompletionCall(commands)) "${COMP_WORDS[@]}")" -- "$cur") )"#
211211
}
212212
}
213213
}

Tests/ArgumentParserExampleTests/MathExampleTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ _math_stats_stdev() {
325325
_math_stats_quantiles() {
326326
opts="--file --directory --shell --custom --version -h --help"
327327
opts="$opts alphabet alligator branch braggart"
328-
opts="$opts $(math ---completion stats quantiles -- customArg "$COMP_WORDS")"
328+
opts="$opts $(math ---completion stats quantiles -- customArg "${COMP_WORDS[@]}")"
329329
if [[ $COMP_CWORD == "$1" ]]; then
330330
COMPREPLY=( $(compgen -W "$opts" -- "$cur") )
331331
return
@@ -344,7 +344,7 @@ _math_stats_quantiles() {
344344
return
345345
;;
346346
--custom)
347-
COMPREPLY=( $(compgen -W "$(math ---completion stats quantiles -- --custom "$COMP_WORDS")" -- "$cur") )
347+
COMPREPLY=( $(compgen -W "$(math ---completion stats quantiles -- --custom "${COMP_WORDS[@]}")" -- "$cur") )
348348
return
349349
;;
350350
esac

0 commit comments

Comments
 (0)