Browse code

Move failure trap after functions it uses

Move the failure trap after the functions it uses, so that
"delete_all" is defined when it is triggered.

Change-Id: Icb2465d0f834b8cb2d46dca3c7df4ae06e49d9b5

Ian Wienand authored on 2015/06/30 12:47:51
Showing 1 changed files
... ...
@@ -19,18 +19,6 @@ echo "*********************************************************************"
19 19
 
20 20
 set -o errtrace
21 21
 
22
-trap failed ERR
23
-function failed {
24
-    local r=$?
25
-    set +o errtrace
26
-    set +o xtrace
27
-    echo "Failed to execute"
28
-    echo "Starting cleanup..."
29
-    delete_all
30
-    echo "Finished cleanup"
31
-    exit $r
32
-}
33
-
34 22
 # Print the commands being run so that we can see the command that triggers
35 23
 # an error.  It is also useful for following allowing as the install occurs.
36 24
 set -o xtrace
... ...
@@ -441,6 +429,18 @@ function main {
441 441
     fi
442 442
 }
443 443
 
444
+trap failed ERR
445
+function failed {
446
+    local r=$?
447
+    set +o errtrace
448
+    set +o xtrace
449
+    echo "Failed to execute"
450
+    echo "Starting cleanup..."
451
+    delete_all
452
+    echo "Finished cleanup"
453
+    exit $r
454
+}
455
+
444 456
 # Kick off script
445 457
 # ---------------
446 458