From 74a2762d10e60c77be0be88e7d7bd162c6431b86 Mon Sep 17 00:00:00 2001 From: Toni Kangas Date: Thu, 23 Jun 2022 23:46:49 +0300 Subject: [PATCH] Use line-break as field separator in compgen words input This ensures that completions with whitespace are treated as single completion. Signed-off-by: Toni Kangas --- bash_completionsV2.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bash_completionsV2.go b/bash_completionsV2.go index 1810b2e7..0de86096 100644 --- a/bash_completionsV2.go +++ b/bash_completionsV2.go @@ -247,7 +247,8 @@ __%[1]s_handle_standard_completion_case() { # Short circuit to optimize if we don't have descriptions if [[ "${completions[*]}" != *$tab* ]]; then - IFS=$'\n' read -ra COMPREPLY -d '' < <(compgen -W "${completions[*]}" -- "$cur") + local compgen_words=$(printf "%%s\n" "${completions[@]}") + IFS=$'\n' read -ra COMPREPLY -d '' < <(IFS=$'\n' compgen -W "${compgen_words}" -- "$cur") # If there is a single completion left, escape the completion if ((${#COMPREPLY[*]} == 1)); then