From 0e5d0483e5596e200430d28356b808af76806439 Mon Sep 17 00:00:00 2001 From: johnraff <github@rafflesnagoya.com> Date: Fri, 1 May 2020 11:23:39 +0900 Subject: Replace 'which' with 'command -v' to test for the existance of an executable This is considered to be more robust. Two instances remain: scripts/build/chroot_archives, line 257: if [ "${LB_APT}" = "aptitude" ] && [ ! $(Chroot chroot "which aptitude") ] The command is run inside a chroot where the environment might be special, and would need further testing. manpages/Makefile, line 42: @if [ ! -x "$$(which po4a 2>/dev/null)" ]; \ I am insufficiently familiar with makefile syntax to edit this. --- functions/architectures.sh | 2 +- functions/configuration.sh | 6 +++--- functions/losetup.sh | 2 +- functions/man.sh | 2 +- functions/packages.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'functions') diff --git a/functions/architectures.sh b/functions/architectures.sh index 285c681d4..62b7b15d7 100755 --- a/functions/architectures.sh +++ b/functions/architectures.sh @@ -53,7 +53,7 @@ Check_architectures () Check_crossarchitectures () { local HOST - if [ $(which dpkg) ] + if command -v dpkg >/dev/null then HOST="$(dpkg --print-architecture)" else diff --git a/functions/configuration.sh b/functions/configuration.sh index 4adba4485..2fba5a148 100755 --- a/functions/configuration.sh +++ b/functions/configuration.sh @@ -36,7 +36,7 @@ Prepare_config () LB_SYSTEM="${LB_SYSTEM:-live}" - if [ $(which lsb_release) ] + if command -v lsb_release >/dev/null then local _DISTRIBUTOR _DISTRIBUTOR="$(lsb_release -is | tr "[A-Z]" "[a-z]")" @@ -66,7 +66,7 @@ Prepare_config () LIVE_IMAGE_TYPE="${LB_IMAGE_TYPE}" if [ -z "${LB_ARCHITECTURE}" ]; then - if [ $(which dpkg) ]; then + if command -v dpkg >/dev/null; then LB_ARCHITECTURE="$(dpkg --print-architecture)" else case "$(uname -m)" in @@ -688,7 +688,7 @@ Validate_config_permitted_values () # Check option combinations and other extra stuff Validate_config_dependencies () { - if [ "${LB_BINARY_FILESYSTEM}" = "ntfs" ] && [ ! $(which ntfs-3g) ]; then + if [ "${LB_BINARY_FILESYSTEM}" = "ntfs" ] && ! command -v ntfs-3g >/dev/null; then Echo_error "Using ntfs as the binary filesystem is currently only supported if ntfs-3g is installed on the host system." exit 1 fi diff --git a/functions/losetup.sh b/functions/losetup.sh index c91852f26..6774646ff 100755 --- a/functions/losetup.sh +++ b/functions/losetup.sh @@ -22,7 +22,7 @@ Lodetach () # Changes to block devices result in uevents which trigger rules which in # turn access the loop device (ex. udisks-part-id, blkid) which can cause # a race condition. We call 'udevadm settle' to help avoid this. - if [ $(which udevadm) ] + if command -v udevadm >/dev/null then udevadm settle fi diff --git a/functions/man.sh b/functions/man.sh index d5cdbb31b..472d20663 100755 --- a/functions/man.sh +++ b/functions/man.sh @@ -13,7 +13,7 @@ Man () { local BASENAME BASENAME=$(basename ${0}) - if [ $(which man) ] + if command -v man >/dev/null then case $BASENAME in $PROGRAM) diff --git a/functions/packages.sh b/functions/packages.sh index 0fd057ec7..5c7529051 100755 --- a/functions/packages.sh +++ b/functions/packages.sh @@ -82,7 +82,7 @@ Check_installed () INSTALL_STATUS=1 fi else - if [ $(which dpkg-query) ] + if command -v dpkg-query >/dev/null then if dpkg-query -s "${PACKAGE}" 2> /dev/null | grep -qs "Status: install" then -- cgit v1.2.3