Fixes issue 232

Fixes issue 232 that occurs in at least bash v4.2.25 where "nvm ls" returns "N/A" no matter how many versions of node have been installed.  The fix uses a combination of the find, tr and basename commands instead of basename only.  Tested in bash v3.2.48 and v4.2.25 and zsh v4.3.11.
master
Donovan James King 2013-05-13 14:35:36 -05:00
parent 367ae728fb
commit bc04ed3ece
1 changed files with 4 additions and 1 deletions

5
nvm.sh
View File

@ -79,7 +79,10 @@ nvm_ls()
if [[ "$PATTERN" == v?*.?*.?* ]]; then
VERSIONS="$PATTERN"
else
VERSIONS=`nvm_set_nullglob; basename $NVM_DIR/v${PATTERN}* 2>/dev/null | sort -t. -k 1.2,1n -k 2,2n -k 3,3n`
VERSIONS=`find $NVM_DIR -type d -name "v$PATTERN*" -print \
| tr '\n' '\0' \
| xargs -0 -n 1 basename 2>/dev/null \
| sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n`
fi
if [ ! "$VERSIONS" ]; then
echo "N/A"