From 22975ebb0636afba2e5d97649c29b98bebd9a1ae Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ed=C3=AAnis=20Freindorfer=20Azevedo?= Date: Mon, 6 Sep 2021 17:42:23 -0300 Subject: [PATCH] Check completion for prefixes names. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- config/bash/lxc.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 -- 2.47.2