Merge pull request #377 from koenpunt/remove-obscure-echo-test
Replaced echo for printf when using formatted stringsmaster
commit
4f9324c439
31
nvm.sh
31
nvm.sh
|
@ -26,9 +26,6 @@ if [ ! -d "$NVM_DIR" ]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DASH_E=""
|
|
||||||
[ -z "$(echo -n -e)" ] && DASH_E="-e"
|
|
||||||
|
|
||||||
# Setup mirror location if not already set
|
# Setup mirror location if not already set
|
||||||
if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
|
if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then
|
||||||
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
|
export NVM_NODEJS_ORG_MIRROR="http://nodejs.org/dist"
|
||||||
|
@ -140,24 +137,19 @@ nvm_checksum() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
colorize_version() {
|
|
||||||
if [ -n "$DASH_E" ]; then
|
|
||||||
echo $DASH_E "\033[0;34m$1\033[0m"
|
|
||||||
else
|
|
||||||
echo $1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
print_versions() {
|
print_versions() {
|
||||||
local VERSION
|
local VERSION
|
||||||
local PADDED_VERSION
|
local FORMAT
|
||||||
for VERSION in $1; do
|
local CURRENT=`nvm_version current`
|
||||||
PADDED_VERSION=`printf '%10s' $VERSION`
|
echo "$1" | while read VERSION; do
|
||||||
if [ -d "$NVM_DIR/$VERSION" ]; then
|
if [ "$VERSION" == "$CURRENT" ]; then
|
||||||
colorize_version "$PADDED_VERSION"
|
FORMAT='\033[0;32m-> %9s\033[0m'
|
||||||
|
elif [ -d "$NVM_DIR/$VERSION" ]; then
|
||||||
|
FORMAT='\033[0;34m%12s\033[0m'
|
||||||
else
|
else
|
||||||
echo "$PADDED_VERSION"
|
FORMAT='%12s'
|
||||||
fi
|
fi
|
||||||
|
printf "$FORMAT\n" $VERSION
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,7 +467,6 @@ nvm() {
|
||||||
"ls" | "list" )
|
"ls" | "list" )
|
||||||
print_versions "`nvm_ls $2`"
|
print_versions "`nvm_ls $2`"
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
printf "current: \t"; nvm_version current
|
|
||||||
nvm alias
|
nvm alias
|
||||||
fi
|
fi
|
||||||
return
|
return
|
||||||
|
@ -485,7 +476,7 @@ nvm() {
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
"current" )
|
"current" )
|
||||||
echo $DASH_E -n "current: \t"; nvm_version current
|
nvm_version current
|
||||||
;;
|
;;
|
||||||
"alias" )
|
"alias" )
|
||||||
mkdir -p $NVM_DIR/alias
|
mkdir -p $NVM_DIR/alias
|
||||||
|
@ -548,7 +539,7 @@ nvm() {
|
||||||
echo "Cache cleared."
|
echo "Cache cleared."
|
||||||
;;
|
;;
|
||||||
"version" )
|
"version" )
|
||||||
colorize_version "`nvm_version $2`"
|
nvm_version $2
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
nvm help
|
nvm help
|
||||||
|
|
|
@ -3,4 +3,4 @@
|
||||||
die () { echo $@ ; exit 1; }
|
die () { echo $@ ; exit 1; }
|
||||||
|
|
||||||
. ../../nvm.sh
|
. ../../nvm.sh
|
||||||
[ `expr "$(nvm current)" : ".*current"` != 0 ] || die "Failed to find current version"
|
[ "$(nvm current)" == `node -v` ] || die "Failed to find current version"
|
||||||
|
|
Loading…
Reference in New Issue