diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2024-07-04 22:27:16 +0300 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2024-07-04 22:27:16 +0300 |
commit | 557aefc3d4947159143a30aa404cd68ab0a65d13 (patch) | |
tree | bc601d6f503f616d7efa109309b6aa1145f4882b | |
parent | tatt: fix template for extra file (diff) | |
download | pkgdev-557aefc3d4947159143a30aa404cd68ab0a65d13.tar.gz pkgdev-557aefc3d4947159143a30aa404cd68ab0a65d13.tar.bz2 pkgdev-557aefc3d4947159143a30aa404cd68ab0a65d13.zip |
bash-completion: use _filedir
This handles spaces and such much much better
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | data/share/bash-completion/completions/pkgdev | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/data/share/bash-completion/completions/pkgdev b/data/share/bash-completion/completions/pkgdev index 09bfbf7..17eb34c 100644 --- a/data/share/bash-completion/completions/pkgdev +++ b/data/share/bash-completion/completions/pkgdev @@ -46,19 +46,14 @@ _pkgdev() { COMPREPLY=($(compgen -W "${base_options}" -- "${cur}")) # find the subcommand - while [[ "${i}" -lt "${COMP_CWORD}" ]]; do - local s="${COMP_WORDS[i]}" - case "${s}" in - -*) ;; - *) - cmd="${s}" - break - ;; - esac - ((i++)) + for (( i=1; i < COMP_CWORD; i++ )); do + if [[ ${COMP_WORDS[i]} != -* ]]; then + cmd=${COMP_WORDS[i]} + break + fi done - if [[ "${i}" -eq "${COMP_CWORD}" ]]; then + if (( i == COMP_CWORD )); then COMPREPLY+=($(compgen -W "${subcommands}" -- "${cur}")) return fi @@ -88,7 +83,7 @@ _pkgdev() { COMPREPLY=() ;; -M | --message-template) - COMPREPLY=($(compgen -f -- "${cur}")) + _filedir ;; -s | --scan | --mangle) COMPREPLY=($(compgen -W "${boolean_options}" -- "${cur}")) @@ -108,7 +103,7 @@ _pkgdev() { case "${prev}" in -d | --distdir) - COMPREPLY=($(compgen -d -- "${cur}")) + _filedir -d ;; *) COMPREPLY+=($(compgen -W "${subcmd_options}" -- "${cur}")) @@ -224,10 +219,10 @@ _pkgdev() { COMPREPLY=() ;; --template-file) - COMPREPLY=($(compgen -f -- "${cur}")) + _filedir ;; --logs-dir) - COMPREPLY=($(compgen -d -- "${cur}")) + _filedir -d ;; --extra-env-file) if [[ -d /etc/portage/env/ ]]; then @@ -264,7 +259,7 @@ _pkgdev() { COMPREPLY=() ;; --dot) - COMPREPLY=($(compgen -f -- "${cur}")) + _filedir ;; *) COMPREPLY+=($(compgen -W "${subcmd_options}" -- "${cur}")) |