summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacob Keller <jacob.e.keller@intel.com>2014-04-09 15:26:05 -0700
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2014-04-25 15:37:43 -0700
commitf491665839e8b033d4e20cfe2ea1c66609f2adde (patch)
tree306837612b3d10601111f3b9a9f25b20b48b0293
parent23ba225e12503e5443c9de01b6fbd80aca62d6f6 (diff)
downloadaiaiai-f491665839e8b033d4e20cfe2ea1c66609f2adde.tar.gz
aiaiai-email-test-patchset: correct hook calling to actually grab error
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>
-rwxr-xr-xemail/aiaiai-email-test-patchset30
1 files changed, 17 insertions, 13 deletions
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index 0376957..af5f18b 100755
--- a/email/aiaiai-email-test-patchset
+++ b/email/aiaiai-email-test-patchset
@@ -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