From 6a6920aed23a08f9021bac82d330d133aa106c92 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 5 May 2023 17:34:05 +0200 Subject: [PATCH] modalias.prov: use "command" rather than "which" to check existence of commands Signed-off-by: Denys Vlasenko --- modalias.prov | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/modalias.prov b/modalias.prov index edce340..4665f9f 100755 --- a/modalias.prov +++ b/modalias.prov @@ -26,10 +26,12 @@ if ! [ -z "$is_kernel_package" ]; then exit 0 fi -# Check for presence of the commands used -which /sbin/modinfo >/dev/null || exit 0 -which sed >/dev/null || exit 0 -which sort >/dev/null || exit 0 +# Check for presence of the commands used. +# "command" is a builtin, faster to use than fork+execing "which" - see +# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html +command -v /sbin/modinfo >/dev/null || exit 1 +command -v sed >/dev/null || exit 1 +command -v sort >/dev/null || exit 1 print_modaliases() { declare class=$1 variants=$2 pos=$3