Skip to content

Commit 06660cb

Browse files
committed
factored some duplicated code into a function
1 parent 280f06c commit 06660cb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

archive_fusionvm

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,20 @@ SRCPATH=$(cd "$1"; pwd)
1717

1818
echo "SRCPATH is $SRCPATH"
1919

20-
i=0
20+
running=()
2121

2222
# Test whether running .vmx files are inside our path.
23-
running=(${(@f)"$(vmrun list | grep "$SRCPATH")"})
23+
refresh_running() {
24+
running=(${(@f)"$(vmrun list | grep "$SRCPATH")"})
25+
}
26+
27+
refresh_running
2428

2529
# Save this initial list of .vmx files
2630
vmxlist=($running)
2731

32+
i=0
33+
2834
while true; do
2935
echo "Current running VM list is $running"
3036

@@ -44,8 +50,7 @@ while true; do
4450
vmrun suspend "$vmx"
4551
done
4652

47-
# Refresh running VM list
48-
running=(${(@f)"$(vmrun list | grep "$SRCPATH")"})
53+
refresh_running
4954
done
5055

5156
# Test that every VMX in the list has no lockfile; otherwise quit Fusion

0 commit comments

Comments
 (0)