Browse Source

Move pre-post-hook wrapping code to a routine

Alois Mahdal 9 years ago
parent
commit
cf82cfa5f1
1 changed files with 15 additions and 3 deletions
  1. 15
    3
      src/ffoo/saturnin_common.sh

+ 15
- 3
src/ffoo/saturnin_common.sh View File

@@ -55,9 +55,21 @@ saturnin_runsc() {
55 55
         saturnin_help
56 56
         return $FFOO_EXIT_USAGE
57 57
     }
58
+    saturnin_wraphook "$lexpath" "$@"
59
+}
60
+
61
+saturnin_wraphook() {
62
+    #
63
+    # Wrap command "$@" in hooks
64
+    #
65
+    # Run pre hook, then "$@", then post hook.  Always exit
66
+    # with status of "$@", even if hooks fail.  Ignore
67
+    # post-hook if "$@" failed.
68
+    #
69
+    local es=0
58 70
     saturnin_runhook pre
59
-    "$lexpath" "$@" || return $?
60
-    sc_es=$?
71
+    "$@" || return $?
72
+    es=$?
61 73
     saturnin_runhook post
62
-    return $sc_es
74
+    return $es
63 75
 }