mirror of
https://git.proxmox.com/git/mirror_lxc
synced 2025-04-28 16:37:44 +00:00
Improve name completion handling.
Use regex to handle short option `-n`, since short options can be combined (e.g. `-nd`) as long as at max one requires an argument. Also consider the case when the arg for the long option is not given together with `--name=`. Signed-off-by: Edênis Freindorfer Azevedo <edenisfa@gmail.com>
This commit is contained in:
parent
db8b9df555
commit
8aa4490505
@ -27,11 +27,12 @@ _lxc_names() {
|
||||
|
||||
_lxc_append_name() {
|
||||
local vms=$(command lxc-ls)
|
||||
local -r shortoptnamexp="^-[0-9A-Za-mo-z]*n[0-9A-Za-mo-z]*$"
|
||||
# If `--name` or `-n` are present, do not complete with container names.
|
||||
for param in ${words[@]}; do
|
||||
if [[ ${param} =~ ^--name=(.*)$ ]]; then
|
||||
if [[ ${param} =~ ^--name(=(.*))?$ ]]; then
|
||||
return
|
||||
elif [[ ${param} =~ ^-n$ ]]; then
|
||||
elif [[ ${param} =~ ${shortoptnamexp} ]]; then
|
||||
return
|
||||
fi
|
||||
for vm in ${vms[@]}; do
|
||||
|
Loading…
Reference in New Issue
Block a user