From 5c76974cb0e7ab54ddd900785319e3ac6fd2ffa8 Mon Sep 17 00:00:00 2001 From: Arthur Zamarin Date: Thu, 4 Jul 2024 23:06:15 +0300 Subject: [PATCH] bash-completion: use _filedir This handles spaces and such much much better Signed-off-by: Arthur Zamarin --- .../bash-completion/completions/pkgcheck | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/data/share/bash-completion/completions/pkgcheck b/data/share/bash-completion/completions/pkgcheck index 8801391ba..972fc1e5c 100644 --- a/data/share/bash-completion/completions/pkgcheck +++ b/data/share/bash-completion/completions/pkgcheck @@ -43,18 +43,15 @@ _pkgcheck() { COMPREPLY=($(compgen -W "${base_options[*]}" -- "${cur}")) # find the subcommand - for ((i = 1; i < ${COMP_CWORD}; i++)); do - case "${COMP_WORDS[i]}" in - -*) ;; - *) - cmd=${COMP_WORDS[i]} - break - ;; - esac + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ ${COMP_WORDS[i]} != -* ]]; then + cmd=${COMP_WORDS[i]} + break + fi done - if [[ ${i} == ${COMP_CWORD} ]]; then - COMPREPLY+=($(compgen -W "${subcommands[*]}" -- "${cur}")) + if (( i == COMP_CWORD )); then + COMPREPLY+=($(compgen -W "${subcommands}" -- "${cur}")) return fi @@ -73,7 +70,7 @@ _pkgcheck() { case ${prev} in --cache-dir) - COMPREPLY=($(compgen -d -- "${cur}")) + _filedir -d ;; -t | --type) COMPREPLY=($(compgen -W "$(