modalias.prov: use "command" rather than "which" to check existence of commands

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
Denys Vlasenko 2023-05-05 17:34:05 +02:00
parent 0c336570df
commit 6a6920aed2

View File

@ -26,10 +26,12 @@ if ! [ -z "$is_kernel_package" ]; then
exit 0 exit 0
fi fi
# Check for presence of the commands used # Check for presence of the commands used.
which /sbin/modinfo >/dev/null || exit 0 # "command" is a builtin, faster to use than fork+execing "which" - see
which sed >/dev/null || exit 0 # https://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
which sort >/dev/null || exit 0 command -v /sbin/modinfo >/dev/null || exit 1
command -v sed >/dev/null || exit 1
command -v sort >/dev/null || exit 1
print_modaliases() { print_modaliases() {
declare class=$1 variants=$2 pos=$3 declare class=$1 variants=$2 pos=$3