提交 e465ce7d 编写于 作者: F Fam Zheng 提交者: Kevin Wolf

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: NEric Blake <eblake@redhat.com>
Signed-off-by: NFam Zheng <famz@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Message-id: 1416380832-9697-1-git-send-email-famz@redhat.com
Signed-off-by: NStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 4c58e80a
......@@ -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
;;
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册