From: EdĂȘnis Freindorfer Azevedo Date: Fri, 27 Aug 2021 12:11:42 +0000 (-0300) Subject: Add `compopt` call to `__lxc_piped_args`. X-Git-Tag: lxc-5.0.0~91^2~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db8b9df55517b5bdf2ff4d450238de6234eb2c16;p=thirdparty%2Flxc.git Add `compopt` call to `__lxc_piped_args`. 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 --- diff --git a/config/bash/lxc.in b/config/bash/lxc.in index 457a5b80f..f1dc9e217 100644 --- a/config/bash/lxc.in +++ b/config/bash/lxc.in @@ -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 )