Consistent output in different shells (bash, sh, zsh, ksh)

This commit is contained in:
Koen Punt 2013-12-15 14:32:17 +01:00
parent fddb1042f9
commit 6df476cef8
2 changed files with 11 additions and 12 deletions

View File

@ -2,7 +2,7 @@
set -e set -e
function fatalExit (){ fatalExit(){
echo "$@" && exit 1; echo "$@" && exit 1;
} }
@ -16,11 +16,11 @@ fi
# Downloading to $NVM_DIR # Downloading to $NVM_DIR
mkdir -p "$NVM_DIR" mkdir -p "$NVM_DIR"
pushd "$NVM_DIR" > /dev/null echo -ne "\r=> Downloading... \c"
echo -ne "=> Downloading... " curl --silent "$NVM_SOURCE" -o "$NVM_DIR/nvm.sh" || fatalExit "Failed downloading $NVM_SOURCE"
curl --silent "$NVM_SOURCE" -o nvm.sh || fatalExit "Failed downloading $NVM_SOURCE"
echo "Downloaded" echo "Downloaded"
popd > /dev/null
echo
# Detect profile file if not specified as environment variable (eg: NVM_PROFILE=~/.myprofile). # Detect profile file if not specified as environment variable (eg: NVM_PROFILE=~/.myprofile).
if [ ! "$NVM_PROFILE" ]; then if [ ! "$NVM_PROFILE" ]; then
@ -46,7 +46,7 @@ if [ -z "$NVM_PROFILE" ] || [ ! -f "$NVM_PROFILE" ] ; then
echo " OR" echo " OR"
echo "=> Append the following line to the correct file yourself:" echo "=> Append the following line to the correct file yourself:"
echo echo
echo -ne "\t$SOURCE_STR" echo " $SOURCE_STR"
echo echo
else else
if ! grep -qc 'nvm.sh' $NVM_PROFILE; then if ! grep -qc 'nvm.sh' $NVM_PROFILE; then
@ -58,4 +58,5 @@ else
fi fi
fi fi
echo
echo "=> Close and reopen your terminal afterwards to start using NVM" echo "=> Close and reopen your terminal afterwards to start using NVM"

View File

@ -18,10 +18,8 @@ fi
if [ -d "$NVM_DIR" ]; then if [ -d "$NVM_DIR" ]; then
echo "=> NVM is already installed in $NVM_DIR, trying to update" echo "=> NVM is already installed in $NVM_DIR, trying to update"
echo -ne "\r=> " echo -e "\r=> \c"
pushd "$NVM_DIR" > /dev/null (cd "$NVM_DIR" && git pull --no-rebase origin master --quiet)
git pull --no-rebase origin master --quiet
popd > /dev/null
else else
# Cloning to $NVM_DIR # Cloning to $NVM_DIR
mkdir -p "$NVM_DIR" mkdir -p "$NVM_DIR"
@ -54,8 +52,7 @@ if [ -z "$NVM_PROFILE" ] || [ ! -f "$NVM_PROFILE" ] ; then
echo " OR" echo " OR"
echo "=> Append the following line to the correct file yourself:" echo "=> Append the following line to the correct file yourself:"
echo echo
echo -ne "\t$SOURCE_STR" echo " $SOURCE_STR"
echo
echo echo
else else
if ! grep -qc 'nvm.sh' $NVM_PROFILE; then if ! grep -qc 'nvm.sh' $NVM_PROFILE; then
@ -67,4 +64,5 @@ else
fi fi
fi fi
echo
echo "=> Close and reopen your terminal afterwards to start using NVM" echo "=> Close and reopen your terminal afterwards to start using NVM"