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
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"

View File

@ -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"