From bc04ed3ece73d6014e2c229d4036f1322f3b2de7 Mon Sep 17 00:00:00 2001 From: Donovan James King Date: Mon, 13 May 2013 14:35:36 -0500 Subject: [PATCH 1/2] 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. --- nvm.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 10631fe..ed5e343 100755 --- a/nvm.sh +++ b/nvm.sh @@ -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" From d1d53ea97927d76897e38b8b0a11404df2a5312f Mon Sep 17 00:00:00 2001 From: Derek Keller Date: Sun, 9 Jun 2013 21:44:46 -0500 Subject: [PATCH 2/2] Updated fix for issues #232 and #244 Fixes issues #232 and #244 where "nvm ls" returns inconsistent results depending on the number of node versions installed. This updated fix uses the find and sort commands only. Tested in bash v3.2.48 and v4.2.25, and zsh v4.3.11. --- nvm.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/nvm.sh b/nvm.sh index ed5e343..0c16722 100755 --- a/nvm.sh +++ b/nvm.sh @@ -79,9 +79,7 @@ nvm_ls() if [[ "$PATTERN" == v?*.?*.?* ]]; then VERSIONS="$PATTERN" else - VERSIONS=`find $NVM_DIR -type d -name "v$PATTERN*" -print \ - | tr '\n' '\0' \ - | xargs -0 -n 1 basename 2>/dev/null \ + VERSIONS=`find "$NVM_DIR/" -maxdepth 1 -type d -name "v$PATTERN*" -exec basename '{}' ';' \ | sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n` fi if [ ! "$VERSIONS" ]; then