[tip: objtool/core] livepatch/klp-build: add grep-override function
From: tip-bot2 for Joe Lawrence
Date: Wed Mar 18 2026 - 04:28:50 EST
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: e4dbf70615e52255de3ff943ac08e0bbd080dcd6
Gitweb: https://git.kernel.org/tip/e4dbf70615e52255de3ff943ac08e0bbd080dcd6
Author: Joe Lawrence <joe.lawrence@xxxxxxxxxx>
AuthorDate: Tue, 10 Mar 2026 16:37:44 -04:00
Committer: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
CommitterDate: Mon, 16 Mar 2026 12:46:48 -07:00
livepatch/klp-build: add grep-override function
Provide a custom grep() function to catch direct usage of the command.
Bare grep calls are generally incompatible with pipefail and
errexit behavior (where a failed match causes the script to exit).
Developers can still call grep via command grep if that behavior is
explicitly desired.
Acked-by: Song Liu <song@xxxxxxxxxx>
Signed-off-by: Joe Lawrence <joe.lawrence@xxxxxxxxxx>
Link: https://patch.msgid.link/20260310203751.1479229-6-joe.lawrence@xxxxxxxxxx
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
---
scripts/livepatch/klp-build | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index 564985a..cf6c2bf 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -56,6 +56,13 @@ grep0() {
command grep "$@" || true
}
+# Because pipefail is enabled, the grep0 helper should be used instead of
+# grep, otherwise a failed match can propagate to an error.
+grep() {
+ echo "error: $SCRIPT: use grep0 or 'command grep' instead of bare grep" >&2
+ exit 1
+}
+
status() {
echo "$*"
}