From 6df476cef8f04fbcd6ca64b6bbac3fc8117d1fef Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Sun, 15 Dec 2013 14:32:17 +0100 Subject: [PATCH] Consistent output in different shells (bash, sh, zsh, ksh) --- install-gitless.sh | 13 +++++++------ install.sh | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/install-gitless.sh b/install-gitless.sh index 8e9707e..2eca57a 100755 --- a/install-gitless.sh +++ b/install-gitless.sh @@ -2,7 +2,7 @@ set -e -function fatalExit (){ +fatalExit(){ echo "$@" && exit 1; } @@ -16,11 +16,11 @@ fi # Downloading to $NVM_DIR mkdir -p "$NVM_DIR" -pushd "$NVM_DIR" > /dev/null -echo -ne "=> Downloading... " -curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed downloading $NVM_SOURCE" +echo -ne "\r=> Downloading... \c" +curl --silent "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || fatalExit "Failed downloading $NVM_SOURCE" echo "Downloaded" -popd > /dev/null + +echo # Detect profile file if not specified as environment variable (eg: NVM_PROFILE=~/.myprofile). if [ ! "$NVM_PROFILE" ]; then @@ -46,7 +46,7 @@ if [ -z "$NVM_PROFILE" ] || [ ! -f "$NVM_PROFILE" ] ; then echo " OR" echo "=> Append the following line to the correct file yourself:" echo - echo -ne "\t$SOURCE_STR" + echo " $SOURCE_STR" echo else if ! grep -qc 'nvm.sh' $NVM_PROFILE; then @@ -58,4 +58,5 @@ else fi fi +echo echo "=> Close and reopen your terminal afterwards to start using NVM" diff --git a/install.sh b/install.sh index eb1a6f6..9efeb9a 100755 --- a/install.sh +++ b/install.sh @@ -18,10 +18,8 @@ fi if [ -d "$NVM_DIR" ]; then echo "=> NVM is already installed in $NVM_DIR, trying to update" - echo -ne "\r=> " - pushd "$NVM_DIR" > /dev/null - git pull --no-rebase origin master --quiet - popd > /dev/null + echo -e "\r=> \c" + (cd "$NVM_DIR" && git pull --no-rebase origin master --quiet) else # Cloning to $NVM_DIR mkdir -p "$NVM_DIR" @@ -54,8 +52,7 @@ if [ -z "$NVM_PROFILE" ] || [ ! -f "$NVM_PROFILE" ] ; then echo " OR" echo "=> Append the following line to the correct file yourself:" echo - echo -ne "\t$SOURCE_STR" - echo + echo " $SOURCE_STR" echo else if ! grep -qc 'nvm.sh' $NVM_PROFILE; then @@ -67,4 +64,5 @@ else fi fi +echo echo "=> Close and reopen your terminal afterwards to start using NVM"