From 296be19560f679373927657c55ef89b8f25fd08e Mon Sep 17 00:00:00 2001 From: Christophe Martin Date: Tue, 19 Feb 2019 10:41:23 +0100 Subject: [PATCH] handle snapshot completion entirely with awk fixes #5 Also list and complete snapshot uuid. --- VBoxManage | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/VBoxManage b/VBoxManage index 740330e..2d30aec 100644 --- a/VBoxManage +++ b/VBoxManage @@ -271,11 +271,14 @@ _VBoxManage() { snap=$(VBoxManage snapshot "${name//\\/}" \ list | \ grep UUID | - awk -F ': ' '{print $2}' | \ - sed 's/ (.*//' | \ - tr '\n' '|' | \ - sed 's/|$//' | \ - sed 's/\s/\\ /g') + awk -F ': *' -v ORS='|' '/UUID: / { + n=$2; u=$3 + sub(/..UUID/, "", n) + gsub(/ /, "\\ ", n); + sub(/[)].*/, "", u) + print n; print u + }' + ) IFS='|' read -ra snap <<< "$snap" for item in "${snap[@]}"