Commit e4dbf706 authored by Joe Lawrence's avatar Joe Lawrence Committed by Josh Poimboeuf
Browse files

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: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarJoe Lawrence <joe.lawrence@redhat.com>
Link: https://patch.msgid.link/20260310203751.1479229-6-joe.lawrence@redhat.com


Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
parent d36a7343
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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 "$*"
}