From 1b57528f14b851493d1270de3a261c863f04e660 Mon Sep 17 00:00:00 2001 From: Alex Malinovich Date: Thu, 11 Aug 2016 18:51:58 -0700 Subject: [PATCH] Use bash built-in hash to check if programs exist in path --- plexupdate.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 4aac5b5..319eb51 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -66,9 +66,8 @@ DEBIAN_INSTALL="dpkg -i" DISTRO_INSTALL="" # Sanity, make sure wget is in our path... -wget >/dev/null 2>/dev/null -if [ $? -eq 127 ]; then - echo "Error: This script requires wget in the path. It could also signify that you don't have the tool installed." >&2 +if hash wget 2>/dev/null; then + echo "ERROR: This script requires wget in the path. It could also signify that you don't have the tool installed." >&2 exit 1 fi @@ -209,9 +208,8 @@ if [ "${QUIET}" = "yes" ]; then fi if [ "${AUTOUPDATE}" == "yes" ]; then - git >/dev/null 2>/dev/null - if [ $? -eq 127 ]; then - echo "Error: You need to have git installed for this to work" >&2 + if hash git 2>/dev/null; then + echo "ERROR: You need to have git installed for this to work" >&2 cronexit 1 fi pushd "$(dirname "$0")" >/dev/null