From: Joe Lawrence Date: Tue, 10 Mar 2026 20:37:44 +0000 (-0400) Subject: livepatch/klp-build: add grep-override function X-Git-Tag: v7.1-rc1~198^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e4dbf70615e52255de3ff943ac08e0bbd080dcd6;p=thirdparty%2Fkernel%2Flinux.git 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 Signed-off-by: Joe Lawrence Link: https://patch.msgid.link/20260310203751.1479229-6-joe.lawrence@redhat.com Signed-off-by: Josh Poimboeuf --- diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build index 564985a1588a2..cf6c2bf694aae 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 "$*" }