[PATCH aiaiai 1/9] aiaiai-email-test-patchset: correct hook calling to actually grab error
Jacob Keller
jacob.e.keller at intel.com
Wed Apr 9 15:26:05 PDT 2014
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 at intel.com>
---
email/aiaiai-email-test-patchset | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/email/aiaiai-email-test-patchset b/email/aiaiai-email-test-patchset
index 037695740ad5..af5f18b0b7f4 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
--
1.8.3.1
More information about the aiaiai
mailing list