]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
livepatch/klp-build: add grep-override function
authorJoe Lawrence <joe.lawrence@redhat.com>
Tue, 10 Mar 2026 20:37:44 +0000 (16:37 -0400)
committerJosh Poimboeuf <jpoimboe@kernel.org>
Mon, 16 Mar 2026 19:46:48 +0000 (12:46 -0700)
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@kernel.org>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/20260310203751.1479229-6-joe.lawrence@redhat.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
scripts/livepatch/klp-build

index 564985a1588a224ab89c9bb24cea9c49377c94a6..cf6c2bf694aaea0fb5db8b93016ed50c3704c612 100755 (executable)
@@ -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 "$*"
 }