]> www.infradead.org Git - users/dedekind/aiaiai.git/commitdiff
aiaiai-email-test-patchset: correct hook calling to actually grab error
authorJacob Keller <jacob.e.keller@intel.com>
Wed, 9 Apr 2014 22:26:05 +0000 (15:26 -0700)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 25 Apr 2014 22:37:43 +0000 (15:37 -0700)
We can't grab the $? value from inside an if block, as the if statement
already changed the return code. Instead, we just call the hook script
without an error section, and then check for errors afterwards. This
corrects an issue where the return code would always be 0, even if the
command failed.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
email/aiaiai-email-test-patchset

index 037695740ad5ed4ea795c36af40277d7fe43aceb..af5f18b0b7f4b27ac4006952d46cda5f64c7d6a6 100755 (executable)
@@ -288,19 +288,23 @@ hookscript="$(readlink -ev -- $cfg_email_hook)"
 if [ -f "$hookscript" ] && [ -x "$hookscript" ]; then
        # Hook points to an executable file, so we run it
        verbose "Executing \"$hookscript\""
-       if ! "$hookscript" "$cfgfile" "$mbox" > "$hookoutput"; then
-               hookret=$?
-
-               # Error code 127 is an expected output of the hook, and
-               # indicates that we should reject this patch. The reply email
-               # will be sent to the user, and the hook is expected to have
-               # outputted the rejection indication. As a precaution, the
-               # rejection email will include a list of projects supported.
-               if [ "$hookret" -eq "127" ]; then
-                       error_hook_rejected_patch < "$hookoutput"
-               else
-                       error_internal_error_occurred
-               fi
+
+       # Grab the error code here, using an || section to prevent exit on
+       # command failure. Otherwise, the non-zero exit code from the hook
+       # script would crash aiaiai-email-test-patchset
+       hookret="0"
+       "$hookscript" "$cfgfile" "$mbox" > "$hookoutput" || hookret="$?"
+
+       # Error code 127 is an expected output of the hook, and
+       # indicates that we should reject this patch. The reply email
+       # will be sent to the user, and the hook is expected to have
+       # outputted the rejection indication. As a precaution, the
+       # rejection email will include a list of projects supported.
+       if [ "$hookret" -eq "127" ]; then
+               error_hook_rejected_patch < "$hookoutput"
+       elif [ "$hookret" -ne "0" ]; then
+               verbose "Hook exited with error code \"$hookret\"..."
+               error_internal_error_occurred
        fi
 fi