From 1a5ba64b069d9399dcd53560bf6a733b957ed0cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Tue, 31 Aug 2021 07:29:01 -0300 Subject: [PATCH] Add support for comma as a completion word. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For `lxc-ls --groups` and `lxc-autostart --groups`. Support leading comma, trailing comma, embedded double comma. Signed-off-by: Edênis Freindorfer Azevedo --- config/bash/lxc.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/config/bash/lxc.in b/config/bash/lxc.in index 71433aa30..8eb2df3f3 100644 --- a/config/bash/lxc.in +++ b/config/bash/lxc.in @@ -219,7 +219,13 @@ __lxc_piped_args() { prefix=$(__lxc_concat_array_sep "${sep}" "${current[@]}") for comp in "${completion[@]}"; do [[ "${comp}" == "${lastword}" ]] && continue - extcompletion+=("\"${prefix}${comp}\"") + if [[ "${comp}" != "${sep}" ]]; then + extcompletion+=("\"${prefix}${comp}\"") + else + # Trailing sep. + extcompletion+=("\"${prefix}\"") + [[ "${#completion[@]}" -gt 2 ]] && extcompletion+=("\"${prefix}${comp}\"") + fi done fi fi @@ -329,8 +335,7 @@ _lxc_autostart() { return ;; --groups | -g ) - # @TODO: add NULL group as a leading comma, trailing comma, embedded double comma. - __lxc_piped_args "${cur}" ',' $( __lxc_groups ) + __lxc_piped_args "${cur}" ',' $( __lxc_groups ) ',' return ;; esac @@ -754,8 +759,7 @@ _lxc_ls() { return ;; --groups | -g ) - # @TODO: add NULL group as a leading comma, trailing comma, embedded double comma. - __lxc_piped_args "${cur}" ',' $( __lxc_groups ) + __lxc_piped_args "${cur}" ',' $( __lxc_groups ) ',' return ;; --nesting ) -- 2.47.2