mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	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.
This commit is contained in:
		
							
								
								
									
										5
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								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" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user