From 7c3af21ebee07200d16314da97c8b8036719f027 Mon Sep 17 00:00:00 2001 From: David Hagler Date: Fri, 24 Feb 2012 10:52:25 -0600 Subject: [PATCH 1/2] Removed default check for curl, and placed it into nvm function This fixes issue with curl not being installed before nvm is initially sourced and then curl subsequently being installed. removed creation of global curl function (after error detected) which overwrites the system tool, preventing execution of later installed curl binary --- nvm.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/nvm.sh b/nvm.sh index 1f92a5c..f88c632 100755 --- a/nvm.sh +++ b/nvm.sh @@ -10,12 +10,6 @@ if [ ! -d "$NVM_DIR" ]; then export NVM_DIR=$(cd $(dirname ${BASH_SOURCE[0]:-$0}); pwd) fi -# Emulate curl with wget, if necessary -if [ ! `which curl` ]; then - NOCURL='nocurl' - curl() { echo 'Need curl to proceed.' >&2; } -fi - # Expand a version using the version cache nvm_version() { @@ -75,6 +69,11 @@ print_versions() nvm() { + if [ ! `which curl` ]; then + echo 'NVM Needs curl to proceed.' >&2; + return + fi + if [ $# -lt 1 ]; then nvm help return From 45051f4d43b7004ffae414e6b9c7239a2587a510 Mon Sep 17 00:00:00 2001 From: David Hagler Date: Fri, 24 Feb 2012 11:25:27 -0600 Subject: [PATCH 2/2] changed the function to place the curl requirement where it belongs --- nvm.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/nvm.sh b/nvm.sh index f88c632..516f9a0 100755 --- a/nvm.sh +++ b/nvm.sh @@ -69,11 +69,6 @@ print_versions() nvm() { - if [ ! `which curl` ]; then - echo 'NVM Needs curl to proceed.' >&2; - return - fi - if [ $# -lt 1 ]; then nvm help return @@ -105,11 +100,14 @@ nvm() echo ;; "install" ) + if [ ! `which curl` ]; then + echo 'NVM Needs curl to proceed.' >&2; + fi + if [ $# -ne 2 ]; then nvm help return fi - [ "$NOCURL" ] && curl && return VERSION=`nvm_version $2` [ -d "$NVM_DIR/$VERSION" ] && echo "$VERSION is already installed." && return