]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
kresctl: tab-completion: skip program name in client.bash to avoid treating kresctl...
authorFrantisek Tobias <frantisek.tobias@nic.cz>
Fri, 11 Oct 2024 07:12:34 +0000 (09:12 +0200)
committerFrantisek Tobias <frantisek.tobias@nic.cz>
Fri, 11 Oct 2024 07:12:34 +0000 (09:12 +0200)
utils/shell-completion/client.bash

index b3c1941974e132573e25f3f1e7532c1d2feb44b1..e99943aa5be9cc74e22ef676395330beb82bfc95 100644 (file)
@@ -8,14 +8,17 @@ _kresctl_completion()
     cur="${COMP_WORDS[COMP_CWORD]}"
     prev="${COMP_WORDS[COMP_CWORD-1]}"
 
+    # skip kresctl, it is not a valid argument
+    local cmd_words=("${COMP_WORDS[@]:1}")
+
     # check if there is a word is empty
     # that means there is a space after last non-empty word
     if [[ -z "$cur" ]]
     then
         # no word to complete, return all posible options
-        opts=$(kresctl completion --bash --space "${COMP_WORDS}")
+        opts=$(kresctl completion --bash --space "${cmd_words[@]}")
     else
-        opts=$(kresctl completion --bash "${COMP_WORDS}")
+        opts=$(kresctl completion --bash "${cmd_words[@]}")
     fi
 
     # if there is no completion from kresctl