From 4298237cf922a63ce42ba80157ffe332c54dc7d5 Mon Sep 17 00:00:00 2001 From: Roman Dobosz Date: Sun, 12 Mar 2023 18:44:37 +0100 Subject: [PATCH] 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 [--option1|--option2] [--option3=optarg ] There is no need to get it as in old format from now on. --- VBoxManage | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/VBoxManage b/VBoxManage index 49b370d..f29f59f 100644 --- a/VBoxManage +++ b/VBoxManage @@ -484,21 +484,15 @@ _VBoxManage() { 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 | \ - grep -E -o "^\s\s[a-z]+ " | \ - grep -v VBoxManage | \ - awk '{print $1}'| \ + grep VBoxManage | \ + awk '{print $2}'| \ + grep -v '\[' | \ sort | \ 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 COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) return 0