From: EdĂȘnis Freindorfer Azevedo Date: Mon, 6 Sep 2021 20:42:23 +0000 (-0300) Subject: Check completion for prefixes names. X-Git-Tag: lxc-5.0.0~91^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2274666731a72cfe3e5796e7d7fb8f1e418001d;p=thirdparty%2Flxc.git Check completion for prefixes names. If a name is a prefix of another word available for completion, adjust to show all words with given prefix. Signed-off-by: EdĂȘnis Freindorfer Azevedo --- diff --git a/config/bash/lxc.in b/config/bash/lxc.in index a5ed3562c..41d7b6225 100644 --- a/config/bash/lxc.in +++ b/config/bash/lxc.in @@ -39,6 +39,7 @@ __lxc_check_name_present() { mapfile -t names < <(command lxc-ls -1) local -r shortoptnamexp="^-[0-9A-Za-mo-z]*n[0-9A-Za-mo-z]*$" local parsed + local -r current="${cur//[\\\"\']}" mapfile -t names < <(command lxc-ls -1) # If `--name` or `-n` are present, do not complete with container names. for param in "${words[@]}"; do @@ -50,7 +51,9 @@ __lxc_check_name_present() { return 0 fi for name in "${names[@]}"; do - [[ "${parsed}" == "${name}" ]] && return 0 + if [[ "${parsed}" == "${name}" ]] && [[ "${current}" != "${parsed}" ]]; then + return 0 + fi done done return 1