From c878512a070de690ae92dcbf50b990cfc05651bf Mon Sep 17 00:00:00 2001 From: claustromaniac <20734810+claustromaniac@users.noreply.github.com> Date: Sun, 18 Nov 2018 17:54:05 -0300 Subject: [PATCH] abort if neither curl nor wget are available Additionally, hide the output of those checks. fixes #537 --- updater.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/updater.sh b/updater.sh index 6e69bbd..c66ff5e 100755 --- a/updater.sh +++ b/updater.sh @@ -16,9 +16,14 @@ DOWNLOAD_TO_STDOUT="curl -s" DOWNLOAD_TO_FILE="curl -O" # Use wget if curl is not available. -if [[ -z $(command -v "curl") ]]; then - DOWNLOAD_TO_STDOUT="wget --quiet --output-document=-" - DOWNLOAD_TO_FILE="wget" +if [[ -z $(command -v "curl") ]] > /dev/null 2>&1; then + if [[ $(command -v "wget") ]] > /dev/null 2>&1; then + DOWNLOAD_TO_STDOUT="wget --quiet --output-document=-" + DOWNLOAD_TO_FILE="wget" + else + echo -e "This script requires either curl or wget to be installed.\nProcess aborted" + exit 0 + fi fi ## get the full path of this script (readlink for Linux, greadlink for Mac with coreutils installed) @@ -112,11 +117,11 @@ else if [ $update_available = "no" ]; then main else - ## there is an update available + ## there is an update available if [ $update_pref = "-update" ]; then ## update without asking update_script - else + else read -p "There is a newer version of updater.sh available. Download and execute? Y/N? " -n 1 -r echo -e "\n\n" if [[ $REPLY =~ ^[Yy]$ ]]; then