From a87a9bb63bba47f468651ba79cb0d321f82339ac Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Sun, 17 May 2020 11:17:45 -0400 Subject: [PATCH] bin: Use `command` to check for commands `command` is more idiomatic than `hash`. (Also, `hash` has side effects.) --- bin/buildForWindows.sh | 8 +++++--- bin/installDeps.sh | 6 ++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/buildForWindows.sh b/bin/buildForWindows.sh index 157233744..90bf187ae 100755 --- a/bin/buildForWindows.sh +++ b/bin/buildForWindows.sh @@ -1,5 +1,7 @@ #!/bin/sh +is_cmd() { command -v "$@" >/dev/null 2>&1; } + # Move to the folder where ep-lite is installed cd $(dirname $0) @@ -9,19 +11,19 @@ if [ -d "../bin" ]; then fi # Is wget installed? -hash wget > /dev/null 2>&1 || { +is_cmd wget || { echo "Please install wget" >&2 exit 1 } # Is zip installed? -hash zip > /dev/null 2>&1 || { +is_cmd zip || { echo "Please install zip" >&2 exit 1 } # Is zip installed? -hash unzip > /dev/null 2>&1 || { +is_cmd unzip || { echo "Please install unzip" >&2 exit 1 } diff --git a/bin/installDeps.sh b/bin/installDeps.sh index cbfb6b485..30c42df54 100755 --- a/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -8,6 +8,8 @@ REQUIRED_NODE_MINOR=13 REQUIRED_NPM_MAJOR=5 REQUIRED_NPM_MINOR=5 +is_cmd() { command -v "$@" >/dev/null 2>&1; } + require_minimal_version() { PROGRAM_LABEL="$1" VERSION_STRING="$2" @@ -58,13 +60,13 @@ fi # Is node installed? # Not checking io.js, default installation creates a symbolic link to node -hash node > /dev/null 2>&1 || { +is_cmd node || { echo "Please install node.js ( https://nodejs.org )" >&2 exit 1 } # Is npm installed? -hash npm > /dev/null 2>&1 || { +is_cmd npm || { echo "Please install npm ( https://npmjs.org )" >&2 exit 1 }