summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Frolov <sfrolov@google.com>2021-01-19 18:44:53 -0700
committerCommit Bot <commit-bot@chromium.org>2021-01-21 02:43:05 +0000
commitc7635b2998c2466db3348705c10cc8f38cea42c2 (patch)
tree1b6c60ece7f4c5b50be73ff063a89b5d6fda0ed3
parent223d69ba02100fbd3d7e25095bcbd220ba9b1b8e (diff)
downloadvboot-c7635b2998c2466db3348705c10cc8f38cea42c2.tar.gz
ensure_not_tainted_license: fix exit codes
grep returns exit code 1, if pattern was not found, and due to `set -e` ensure_not_tainted_license.sh exits immediately with code 1. This change fixes it. This change also ensures that the correct code 1 is returned when the pattern is found. BUG=chromium:1163996 TEST=N/A BRANCH=none Signed-off-by: Sergey Frolov <sfrolov@google.com> Change-Id: Idd33cec8795420ca1aab9ab1490a338a04d20257 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/2638856 Tested-by: George Engelbrecht <engeg@google.com> Commit-Queue: George Engelbrecht <engeg@google.com> Reviewed-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: George Engelbrecht <engeg@google.com>
-rwxr-xr-xscripts/image_signing/ensure_not_tainted_license.sh6
1 files changed, 5 insertions, 1 deletions
diff --git a/scripts/image_signing/ensure_not_tainted_license.sh b/scripts/image_signing/ensure_not_tainted_license.sh
index daa00b55..7eab1c9a 100755
--- a/scripts/image_signing/ensure_not_tainted_license.sh
+++ b/scripts/image_signing/ensure_not_tainted_license.sh
@@ -48,7 +48,10 @@ main() {
fi
tainted_tag="<!-- tainted -->"
- tainted_status=$(grep "${tainted_tag}" "${license}")
+ # Add "|| :" to the grep command to prevent it from returning error code 1 if
+ # no match is found, which would cause the script to exit immediately with
+ # error code 1 due to set -e.
+ tainted_status=$(grep "${tainted_tag}" "${license}") || :
if [[ -n "${tainted_status}" ]]; then
echo "${license}:"
echo "License file contains packages with LICENSE=TAINTED."
@@ -61,6 +64,7 @@ main() {
/^[[:space:]]*$/d
p
}' "${license}"
+ exit 1
fi
exit 0
}