From: Chris Morgan Subject: [PATCH 1/2] wineinstall - Switch from 'which' to 'type' to fix detection of programs Message-Id: <20170225003026.4695-1-chmorgan@gmail.com> Date: Fri, 24 Feb 2017 19:30:25 -0500 Use of 'which' was resulting in programs like rpm and wine being found when they didn't exist. 'which' has different behavior on different systems. For example, on Fedora 25: $>which blah /usr/bin/which: no blah in (/usr/lib64/qt-3.3/bin... Means that "if [ -x `which blah` ] will always be true as /usr/bin/which always exists. 'type' exits with 0 if the program is found, non-zero if not. Tested under bash, ksh, and csh. Signed-off-by: Chris Morgan --- tools/wineinstall | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/wineinstall b/tools/wineinstall index e8e22bf..bfd62e3 100755 --- a/tools/wineinstall +++ b/tools/wineinstall @@ -70,7 +70,7 @@ then fi # check whether RPM installed, and if it is, remove any old wine rpm. -if [ -x `which rpm 2>/dev/null` ]; then +if type rpm &>/dev/null; then if [ -n "`rpm -qi wine 2>/dev/null|grep "^Name"`" ]; then echo "Warning: Old Wine RPM install detected. Do you want to remove it first?" conf_yesno_answer "(yes/no) " @@ -96,7 +96,7 @@ if [ -x `which rpm 2>/dev/null` ]; then fi # check whether wine binary still available -if [ -x `which wine 2>/dev/null` ] && [ -n "`wine --version 2>/dev/null`" ] +if type wine &>/dev/null && [ -n "`wine --version 2>/dev/null`" ] then echo "Warning !! wine binary (still) found, which may indicate" echo "a (conflicting) previous installation." -- 2.9.3