Changed a way how vboxmanage commands are obtained.

Starting from 7.x version of VirtualBox, vboxmanage command help gives
its usage with one or more lines per command, like:

  VBoxManage command <args> [--option1|--option2] [--option3=optarg ]

There is no need to get it as in old format from now on.
This commit is contained in:
2023-03-12 18:44:37 +01:00
parent c7a5fc729c
commit 4298237cf9

View File

@@ -484,21 +484,15 @@ _VBoxManage() {
fi fi
fi fi
# all possible commands for the VBoxManage # all possible commands for the VBoxManage. Starting from VirtualBox 7.x all
# commands are listed as ` VBoxManage commandname ` in a help.
opts=$(VBoxManage -q help | \ opts=$(VBoxManage -q help | \
grep -E -o "^\s\s[a-z]+ " | \ grep VBoxManage | \
grep -v VBoxManage | \ awk '{print $2}'| \
awk '{print $1}'| \ grep -v '\[' | \
sort | \ sort | \
uniq) uniq)
# Add commands which are defined as ` VBoxManage commandname ` in a help.
opts="${opts} $(VBoxManage -q help | \
grep -E -o '^\s\s[a-zA-Z]+\s[a-z]+' | \
awk '{print $2}'| \
sort | \
uniq)"
if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then if [[ ${cur} == "-q" || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0