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
parent
367ae728fb
commit
bc04ed3ece
5
nvm.sh
5
nvm.sh
|
@ -79,7 +79,10 @@ nvm_ls()
|
||||||
if [[ "$PATTERN" == v?*.?*.?* ]]; then
|
if [[ "$PATTERN" == v?*.?*.?* ]]; then
|
||||||
VERSIONS="$PATTERN"
|
VERSIONS="$PATTERN"
|
||||||
else
|
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
|
fi
|
||||||
if [ ! "$VERSIONS" ]; then
|
if [ ! "$VERSIONS" ]; then
|
||||||
echo "N/A"
|
echo "N/A"
|
||||||
|
|
Loading…
Reference in New Issue