myvbox-stop-all: added support for spaces in the response from "vboxmanage list runningvms".
--- a/.bashrc Tue Jun 07 13:41:05 2022 +0300
+++ b/.bashrc Wed Jun 08 00:39:34 2022 +0300
@@ -329,8 +329,11 @@
total: %{time_total}\n" "$@"
}
-myvbox-halt-all() {
- vboxmanage list runningvms |& tr -d '\r' | while read name uuid; do
- vboxmanage controlvm "$uuid" acpipowerbutton
+myvbox-stop-all() {
+ VBoxManage list runningvms |& while read line; do
+ # Parse UUID in: "Name with spaces" {UUID}
+ line=${line##*'{'}
+ line=${line%'}'*}
+ VBoxManage controlvm "$uuid" acpipowerbutton
done
}