From a00ee19962e78f51a12b83bb1b11b89dc7512b22 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Mon, 1 Jan 2024 22:02:52 +0900 Subject: [PATCH] fix: use `_comp_compgen_split` while keeping filtering by $cur --- completions/slapt-get | 12 ++++++++---- completions/slapt-src | 15 ++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/completions/slapt-get b/completions/slapt-get index d8c2592a4fb..1dc09e06608 100644 --- a/completions/slapt-get +++ b/completions/slapt-get @@ -60,13 +60,17 @@ _comp_cmd_slapt_get() # slapt-get will fail to search for "^name-version" # it can search for names only local name=${cur%%-*} - COMPREPLY=($(LC_ALL=C "$1" -c "$config" --search "^$name" \ - 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}")) + _comp_compgen_split -l -- "$( + LC_ALL=C "$1" -c "$config" --search "^$name" 2>/dev/null | + LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}" + )" return ;; avl) # --install|-i| - COMPREPLY=($(LC_ALL=C "$1" -c "$config" --available \ - 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}")) + _comp_compgen_split -l -- "$( + LC_ALL=C "$1" -c "$config" --available 2>/dev/null | + LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}" + )" return ;; ins) # --remove|--filelist diff --git a/completions/slapt-src b/completions/slapt-src index 63dab92e7e1..cdf00c202c5 100644 --- a/completions/slapt-src +++ b/completions/slapt-src @@ -56,12 +56,17 @@ _comp_cmd_slapt_src() if [[ $cur == *:* ]]; then local name=${cur%:*} - COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$name" \ - 2>/dev/null | LC_ALL=C command sed -ne \ - "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p;}")) + _comp_compgen_split -l -- "$( + LC_ALL=C + "$1" --config "$config" --search "^$name" 2>/dev/null | + command sed -ne "/^$cur/{s/^$name:\([^ ]*\) .*$/\1/;p;}" + )" else - COMPREPLY=($(LC_ALL=C "$1" --config "$config" --search "^$cur" \ - 2>/dev/null | LC_ALL=C command sed -ne "/^$cur/{s/ .*$//;p;}")) + _comp_compgen_split -l -- "$( + LC_ALL=C + "$1" --config "$config" --search "^$cur" 2>/dev/null | + command sed -ne "/^$cur/{s/ .*$//;p;}" + )" fi } && complete -F _comp_cmd_slapt_src slapt-src