From f0022d29d5cd270de7b3cda60138c9e8760fa272 Mon Sep 17 00:00:00 2001 From: Orion Poplawski Date: Fri, 1 Dec 2023 22:09:15 -0700 Subject: [PATCH] Fix bash completion with multiple file arguments (#746) --- mock/etc/bash_completion.d/mock | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mock/etc/bash_completion.d/mock b/mock/etc/bash_completion.d/mock index 922a25267..3ba3dce8d 100644 --- a/mock/etc/bash_completion.d/mock +++ b/mock/etc/bash_completion.d/mock @@ -30,8 +30,13 @@ _mock() local cfgdirs=( /etc/mock "$HOME/.config/mock" ) local count=0 + local prevopt for word in "${words[@]}" ; do - [[ $count -eq $cword ]] && break + if [[ $count -eq $cword ]] ; then + [[ ${word:0:1} == - ]] && prevopt= + break + fi + [[ ${word:0:1} == - ]] && prevopt=$word if [[ "$word" == --configdir ]] ; then cfgdirs=( "${words[((count+1))]}" ) elif [[ "$word" == --configdir=* ]] ; then @@ -40,7 +45,7 @@ _mock() count=$((++count)) done - case "$prev" in + case "$prevopt" in -h|--help|--version) # no further arguments are accepted after the above arguments return