From 25ca41c9dc1977766223112c979ff269bb97bda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Wed, 12 Mar 2014 09:07:48 -0400 Subject: [PATCH 1/3] Detect if curl or wget is installed --- install-gitless.sh | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/install-gitless.sh b/install-gitless.sh index b5313c8..e6cb5cd 100755 --- a/install-gitless.sh +++ b/install-gitless.sh @@ -17,7 +17,16 @@ fi mkdir -p "$NVM_DIR" pushd "$NVM_DIR" > /dev/null echo -ne "=> Downloading... " -curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed"; + +# Detect if curl or wget is installed to download NVM_SOURCE +if type curl > /dev/null 2>&1; then + curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed"; +elif type wget > /dev/null 2>&1; then + wget --quiet "$NVM_SOURCE" -O nvm.sh || fatalExit "Failed"; +else + fatalExit "Must have curl or wget to install nvm"; +fi + echo "Downloaded" popd > /dev/null @@ -26,9 +35,9 @@ if [ ! -z "$1" ]; then PROFILE="$1" else if [ -f "$HOME/.bash_profile" ]; then - PROFILE="$HOME/.bash_profile" + PROFILE="$HOME/.bash_profile" elif [ -f "$HOME/.profile" ]; then - PROFILE="$HOME/.profile" + PROFILE="$HOME/.profile" fi fi @@ -36,9 +45,9 @@ SOURCE_STR="[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh" # This loads NVM" if [ -z "$PROFILE" ] || [ ! -f "$PROFILE" ] ; then if [ -z $PROFILE ]; then - echo "=> Profile not found" + echo "=> Profile not found" else - echo "=> Profile $PROFILE not found" + echo "=> Profile $PROFILE not found" fi echo "=> Append the following line to the correct file yourself" echo From b90a0a811ec215ab75773b2587e3b61fc93de035 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Wed, 12 Mar 2014 14:33:00 -0400 Subject: [PATCH 2/3] Use 2-space indentation for consistency --- install-gitless.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/install-gitless.sh b/install-gitless.sh index e6cb5cd..075516e 100755 --- a/install-gitless.sh +++ b/install-gitless.sh @@ -1,16 +1,16 @@ #!/bin/bash function fatalExit (){ - echo "$@" && exit 1; + echo "$@" && exit 1; } # an alternative URL that could be used: https://github.com/creationix/nvm/tarball/master if [ "$NVM_SOURCE" = "" ]; then - NVM_SOURCE="https://raw.github.com/creationix/nvm/master/nvm.sh" + NVM_SOURCE="https://raw.github.com/creationix/nvm/master/nvm.sh" fi if [ "$NVM_DIR" = "" ]; then - NVM_DIR="$HOME/.nvm" + NVM_DIR="$HOME/.nvm" fi # Downloading to $NVM_DIR @@ -20,11 +20,11 @@ echo -ne "=> Downloading... " # Detect if curl or wget is installed to download NVM_SOURCE if type curl > /dev/null 2>&1; then - curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed"; + curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed"; elif type wget > /dev/null 2>&1; then - wget --quiet "$NVM_SOURCE" -O nvm.sh || fatalExit "Failed"; + wget --quiet "$NVM_SOURCE" -O nvm.sh || fatalExit "Failed"; else - fatalExit "Must have curl or wget to install nvm"; + fatalExit "Must have curl or wget to install nvm"; fi echo "Downloaded" From 966ff0e1b0a04fd0977bff44c93e088087b076cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Padilla?= Date: Thu, 13 Mar 2014 10:31:34 -0400 Subject: [PATCH 3/3] Fix for running with bash, sh, and zsh --- install-gitless.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-gitless.sh b/install-gitless.sh index 075516e..56b2836 100755 --- a/install-gitless.sh +++ b/install-gitless.sh @@ -1,6 +1,6 @@ #!/bin/bash -function fatalExit (){ +fatalExit (){ echo "$@" && exit 1; }