From 01c1bf8d8ed5cfe257e414950354f12bab6d9a5c Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 5 Feb 2021 14:23:11 +0100 Subject: [PATCH] btrfs-progs: tests: replace which by type -p In some environments the which utility might not be available and the shell builtin 'type -p' is readily available. Signed-off-by: David Sterba --- tests/clean-tests.sh | 2 +- tests/cli-tests.sh | 2 +- tests/common | 4 ++-- tests/convert-tests.sh | 2 +- tests/fuzz-tests.sh | 2 +- tests/misc-tests.sh | 2 +- tests/mkfs-tests.sh | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/clean-tests.sh b/tests/clean-tests.sh index e01b40c9..547377bd 100755 --- a/tests/clean-tests.sh +++ b/tests/clean-tests.sh @@ -11,7 +11,7 @@ if [ -z "$TOP" ]; then INTERNAL_BIN="$TOP" else # external, defaults to system binaries - TOP=$(dirname `which btrfs`) + TOP=$(dirname `type -p btrfs`) TEST_TOP="$SCRIPT_DIR" INTERNAL_BIN="$TEST_TOP" fi diff --git a/tests/cli-tests.sh b/tests/cli-tests.sh index d8cd0672..9901d2dc 100755 --- a/tests/cli-tests.sh +++ b/tests/cli-tests.sh @@ -12,7 +12,7 @@ if [ -z "$TOP" ]; then INTERNAL_BIN="$TOP" else # external, defaults to system binaries - TOP=$(dirname `which btrfs`) + TOP=$(dirname `type -p btrfs`) TEST_TOP="$SCRIPT_DIR" INTERNAL_BIN="$TEST_TOP" fi diff --git a/tests/common b/tests/common index de8a47cf..852793d2 100644 --- a/tests/common +++ b/tests/common @@ -393,7 +393,7 @@ check_prereq() check_global_prereq() { - which "$1" &> /dev/null + type -p "$1" &> /dev/null if [ $? -ne 0 ]; then _fail "Failed system wide prerequisities: $1"; fi @@ -405,7 +405,7 @@ check_dm_target_support() { setup_root_helper - which dmsetup &> /dev/null + type -p dmsetup &> /dev/null if [ $? -ne 0 ]; then _not_run "This test requires dmsetup tool"; fi diff --git a/tests/convert-tests.sh b/tests/convert-tests.sh index 24b3ec0d..2074fd6d 100755 --- a/tests/convert-tests.sh +++ b/tests/convert-tests.sh @@ -13,7 +13,7 @@ if [ -z "$TOP" ]; then INTERNAL_BIN="$TOP" else # external, defaults to system binaries - TOP=$(dirname `which btrfs`) + TOP=$(dirname `type -p btrfs`) TEST_TOP="$SCRIPT_DIR" INTERNAL_BIN="$TEST_TOP" fi diff --git a/tests/fuzz-tests.sh b/tests/fuzz-tests.sh index 0ba8f1e1..8d49ee8a 100755 --- a/tests/fuzz-tests.sh +++ b/tests/fuzz-tests.sh @@ -12,7 +12,7 @@ if [ -z "$TOP" ]; then INTERNAL_BIN="$TOP" else # external, defaults to system binaries - TOP=$(dirname `which btrfs`) + TOP=$(dirname `type -p btrfs`) TEST_TOP="$SCRIPT_DIR" INTERNAL_BIN="$TEST_TOP" fi diff --git a/tests/misc-tests.sh b/tests/misc-tests.sh index 3b49ab01..4b525333 100755 --- a/tests/misc-tests.sh +++ b/tests/misc-tests.sh @@ -12,7 +12,7 @@ if [ -z "$TOP" ]; then INTERNAL_BIN="$TOP" else # external, defaults to system binaries - TOP=$(dirname `which btrfs`) + TOP=$(dirname `type -p btrfs`) TEST_TOP="$SCRIPT_DIR" INTERNAL_BIN="$TEST_TOP" fi diff --git a/tests/mkfs-tests.sh b/tests/mkfs-tests.sh index 150f094f..09a310cc 100755 --- a/tests/mkfs-tests.sh +++ b/tests/mkfs-tests.sh @@ -12,7 +12,7 @@ if [ -z "$TOP" ]; then INTERNAL_BIN="$TOP" else # external, defaults to system binaries - TOP=$(dirname `which btrfs`) + TOP=$(dirname `type -p btrfs`) TEST_TOP="$SCRIPT_DIR" INTERNAL_BIN="$TEST_TOP" fi