From e465ce7d09939d631f1861e0bd8873417c1c0d65 Mon Sep 17 00:00:00 2001 From: Fam Zheng Date: Wed, 19 Nov 2014 15:07:12 +0800 Subject: tests: Use "command -v" instead of which(1) in shell scripts When which(1) is not installed, we would complain "perl not found" because it's the first set_prog_path check. The error message is wrong. Fix it by using "command -v", a native way to query the existence of a command. Suggested-by: Eric Blake Signed-off-by: Fam Zheng Reviewed-by: Eric Blake Message-id: 1416380832-9697-1-git-send-email-famz@redhat.com Signed-off-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- tests/qemu-iotests/common | 8 ++++---- tests/qemu-iotests/common.config | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'tests/qemu-iotests') diff --git a/tests/qemu-iotests/common b/tests/qemu-iotests/common index 9e12bec2bf..bc27f6a073 100644 --- a/tests/qemu-iotests/common +++ b/tests/qemu-iotests/common @@ -289,10 +289,10 @@ testlist options if [ ! -z "$DISPLAY" ] then - which xdiff >/dev/null 2>&1 && diff=xdiff - which gdiff >/dev/null 2>&1 && diff=gdiff - which tkdiff >/dev/null 2>&1 && diff=tkdiff - which xxdiff >/dev/null 2>&1 && diff=xxdiff + command -v xdiff >/dev/null 2>&1 && diff=xdiff + command -v gdiff >/dev/null 2>&1 && diff=gdiff + command -v tkdiff >/dev/null 2>&1 && diff=tkdiff + command -v xxdiff >/dev/null 2>&1 && diff=xxdiff fi ;; diff --git a/tests/qemu-iotests/common.config b/tests/qemu-iotests/common.config index bd6790be63..91a5ef696b 100644 --- a/tests/qemu-iotests/common.config +++ b/tests/qemu-iotests/common.config @@ -47,7 +47,7 @@ export PWD=`pwd` # $1 = prog to look for, $2* = default pathnames if not found in $PATH set_prog_path() { - p=`which $1 2> /dev/null` + p=`command -v $1 2> /dev/null` if [ -n "$p" -a -x "$p" ]; then echo $p return 0 -- cgit v1.2.1