2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 17:24:14 +00:00

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 <edenisfa@gmail.com>
This commit is contained in:
Edênis Freindorfer Azevedo
2021-09-06 17:42:23 -03:00
parent 83ca245532
commit c227466673

View File

@@ -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