From 7e38a877e89dce53cc6b17875ac7ec16c5c2fda9 Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sat, 27 Aug 2022 23:58:26 +0100 Subject: [PATCH] hooks: Fix dkimpy's diff check When running a diff for dkimpy's output, we expect that diff to exit with non-zero code. Unfortunately, the way we set that expectation (by prefixing the diff invocation with `!` is incorrect. Running `! diff ...` will not cause the hook to fail if diff exits with 0, instead `!` will cause the exit code to be ignored. This patch fixes the problem by running `diff ... && exit 1` instead. This was caught by shellcheck, https://www.shellcheck.net/wiki/SC2251. --- etc/chasquid/hooks/post-data | 4 ++-- test/t-19-dkimpy/config/hooks/post-data | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/etc/chasquid/hooks/post-data b/etc/chasquid/hooks/post-data index cbf3c8e..e9fe9ca 100755 --- a/etc/chasquid/hooks/post-data +++ b/etc/chasquid/hooks/post-data @@ -107,9 +107,9 @@ if [ "$AUTH_AS" != "" ] && command -v dkimsign >/dev/null; then # dkimpy doesn't provide a way to just show the new # headers, so we have to compute the difference. # ALSOCHANGE(test/t-19-dkimpy/config/hooks/post-data) - ! diff --changed-group-format='%>' \ + diff --changed-group-format='%>' \ --unchanged-group-format='' \ - "$TF" "$TF.dkimout" + "$TF" "$TF.dkimout" && exit 1 rm "$TF.dkimout" else # driusan/dkim diff --git a/test/t-19-dkimpy/config/hooks/post-data b/test/t-19-dkimpy/config/hooks/post-data index 7a129c1..2fb9f99 100755 --- a/test/t-19-dkimpy/config/hooks/post-data +++ b/test/t-19-dkimpy/config/hooks/post-data @@ -31,9 +31,9 @@ if [ "$AUTH_AS" != "" ]; then # dkimpy doesn't provide a way to just show the new headers, so we # have to compute the difference. # ALSOCHANGE(etc/chasquid/hooks/post-data) - ! diff --changed-group-format='%>' \ + diff --changed-group-format='%>' \ --unchanged-group-format='' \ - "$TF" "$TF.dkimout" + "$TF" "$TF.dkimout" && exit 1 rm "$TF.dkimout" else # NOTE: This is using driusan/dkim instead of dkimpy, because dkimpy can't be