]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Add `compopt` call to `__lxc_piped_args`.
authorEdênis Freindorfer Azevedo <edenisfa@gmail.com>
Fri, 27 Aug 2021 12:11:42 +0000 (09:11 -0300)
committerEdênis Freindorfer Azevedo <edenisfa@gmail.com>
Mon, 6 Sep 2021 20:00:32 +0000 (17:00 -0300)
On pair with how other functions do it. Also, be smarter about adding
whitespace when there are no more completions available for the
parameter.

Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
config/bash/lxc.in

index 457a5b80f4c2a06a0da8b909eb6ecbb45ade257e..f1dc9e217ef5c240ef2f13369749c76800f503cb 100644 (file)
@@ -111,6 +111,10 @@ __lxc_piped_args() {
     fi
 
     COMPREPLY=( $( compgen -P '"' -S '"' -W "$(command echo -e ${extended[@]})" -- "${cur}" ) )
+    # If no more words availables for completion, add space after last match.
+    if [[ "${#completion[@]}" -gt 1 ]]; then
+        compopt -o nospace
+    fi
 }
 
 _lxc_attach() {
@@ -140,12 +144,10 @@ _lxc_attach() {
             ;;
         --elevated-privileges | -e )
             __lxc_piped_args "$cur" '|' CGROUP CAP LSM
-            compopt -o nospace
             return
             ;;
         --namespaces | -s )
             __lxc_piped_args "$cur" '|' MOUNT PID UTSNAME IPC USER NETWORK
-            compopt -o nospace
             return
             ;;
         --remount-sys-proc | -R | --keep-env | --clear-env )
@@ -213,7 +215,6 @@ _lxc_autostart() {
         --groups | -g )
             # @TODO: add NULL group as a leading comma, trailing comma, embedded double comma.
             __lxc_piped_args "$cur" ',' $( __lxc_groups )
-            compopt -o nospace
             return
             ;;
     esac
@@ -638,7 +639,6 @@ _lxc_ls() {
         --groups | -g )
             # @TODO: add NULL group as a leading comma, trailing comma, embedded double comma.
             __lxc_piped_args "$cur" ',' $( __lxc_groups )
-            compopt -o nospace
             return
             ;;
         --nesting )
@@ -902,8 +902,7 @@ _lxc_unshare() {
 
     case $prev in
         --namespaces | -s )
-            __lxc_piped_args "$cur" '|' "MOUNT" "PID" "UTSNAME" "IPC" "USER" "NETWORK"
-            compopt -o nospace
+            __lxc_piped_args "$cur" '|' MOUNT PID UTSNAME IPC USER NETWORK
             return
             ;;
         --user | -u )
@@ -1008,7 +1007,6 @@ _lxc_wait() {
             ;;
         --state | -s )
             __lxc_piped_args "$cur" '|' STOPPED STARTING RUNNING STOPPING ABORTING FREEZING FROZEN THAWED
-            compopt -o nospace
             return
             ;;
         --timeout | -t )