The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7885

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
`_lxd_names()` already made use of list --format=csv so use it consistently for other functions.

While in there, add proper regex grouping to prevent `lxc start <tab>` from matching on container having "STOPPED" in their name.
From e135461684a73b360eb3e8ee80d2129e53ef3e5d Mon Sep 17 00:00:00 2001
From: Simon Deziel <si...@sdeziel.info>
Date: Thu, 17 Sep 2020 17:16:30 -0400
Subject: [PATCH 1/2] bash-completion: use "list --format=csv" consistently

Signed-off-by: Simon Deziel <si...@sdeziel.info>
---
 scripts/bash/lxd-client | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/scripts/bash/lxd-client b/scripts/bash/lxd-client
index 27b1ed2018..d56d45e6ce 100644
--- a/scripts/bash/lxd-client
+++ b/scripts/bash/lxd-client
@@ -16,47 +16,37 @@ _have lxc && {
 
     _lxd_images()
     {
-      COMPREPLY=( $( compgen -W \
-        "$( lxc image list | tail -n +4 | awk '{print $2}' | egrep -v 
'^(\||^$)' )" "$cur" )
-      )
+      COMPREPLY=( $( compgen -W "$( lxc image list --format=csv | cut -d, -f1 
)" "$cur" ) )
     }
 
     _lxd_remotes()
     {
-      COMPREPLY=( $( compgen -W \
-        "$( lxc remote list | tail -n +4 | awk '{print $2}' | egrep -v 
'^(\||^$)' )" "$cur" )
-      )
+      COMPREPLY=( $( compgen -W "$( lxc remote list --format=csv | cut -d, -f1 
)" "$cur" ) )
     }
 
     _lxd_profiles()
     {
-      COMPREPLY=( $( compgen -W "$( lxc profile list | tail -n +4 | awk 
'{print $2}' | egrep -v '^(\||^$)' )" "$cur" ) )
+      COMPREPLY=( $( compgen -W "$( lxc profile list --format=csv | cut -d, 
-f1 )" "$cur" ) )
     }
 
     _lxd_projects()
     {
-      COMPREPLY=( $( compgen -W "$( lxc project list | tail -n +4 | awk 
'{print $2}' | egrep -v '^(\||^$)' )" "$cur" ) )
+      COMPREPLY=( $( compgen -W "$( lxc project list --format=csv | cut -d, 
-f1 )" "$cur" ) )
     }
 
     _lxd_networks()
     {
-      COMPREPLY=( $( compgen -W \
-        "$( lxc network list | tail -n +4 | awk '{print $2}' | egrep -v 
'^(\||^$)' )" "$cur" )
-      )
+      COMPREPLY=( $( compgen -W "$( lxc network list --format=csv | cut -d, 
-f1 )" "$cur" ) )
     }
 
     _lxd_storage_pools()
     {
-      COMPREPLY=( $( compgen -W \
-        "$( lxc storage list | tail -n +4 | awk '{print $2}' | egrep -v 
'^(\||^$)' )" "$cur" )
-      )
+      COMPREPLY=( $( compgen -W "$( lxc storage list --format=csv | cut -d, 
-f1 )" "$cur" ) )
     }
 
     _lxd_storage_volumes()
     {
-      COMPREPLY=( $( compgen -W \
-        "$( lxc storage volume list | tail -n +4 | awk '{print $2}' | egrep -v 
'^(\||^$)' )" "$cur" )
-      )
+      COMPREPLY=( $( compgen -W "$( lxc storage volume list --format=csv | cut 
-d, -f1 )" "$cur" ) )
     }
 
     COMPREPLY=()

From b5af91dfea753718bb033d3c4fb6e8c58d25ee0a Mon Sep 17 00:00:00 2001
From: Simon Deziel <si...@sdeziel.info>
Date: Thu, 17 Sep 2020 17:20:59 -0400
Subject: [PATCH 2/2] bash-completion: use regex grouping for `lxc start`

Signed-off-by: Simon Deziel <si...@sdeziel.info>
---
 scripts/bash/lxd-client | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/bash/lxd-client b/scripts/bash/lxd-client
index d56d45e6ce..37769d8ec9 100644
--- a/scripts/bash/lxd-client
+++ b/scripts/bash/lxd-client
@@ -359,7 +359,7 @@ _have lxc && {
         _lxd_names
         ;;
       "start")
-        _lxd_names "STOPPED|FROZEN"
+        _lxd_names "(STOPPED|FROZEN)"
         ;;
       "stop")
         _lxd_names "RUNNING"
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to