From 6e1c249ecdfeb02120025ac3db155bcc55661df6 Mon Sep 17 00:00:00 2001 From: Mario Idival Date: Thu, 10 Oct 2013 14:30:53 -0300 Subject: [PATCH 01/10] For zsh users i use zsh and i did this update in install.sh local, is good for you too :) --- install.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install.sh b/install.sh index 7833b93..8117dca 100755 --- a/install.sh +++ b/install.sh @@ -25,6 +25,8 @@ if [ ! -z "$1" ]; then else if [ -f "$HOME/.bash_profile" ]; then PROFILE="$HOME/.bash_profile" + elif [ -f "$HOME/.zshrc" ]; then + PROFILE="$HOME/.zshrc" elif [ -f "$HOME/.profile" ]; then PROFILE="$HOME/.profile" fi From 473dd86f48f54897fe8627868407343cc6c9384c Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Wed, 23 Oct 2013 22:14:02 -0700 Subject: [PATCH 02/10] Properly remove the tar file. --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index e4ce9f8..ad98e0d 100755 --- a/nvm.sh +++ b/nvm.sh @@ -262,8 +262,8 @@ nvm() { curl -L -C - --progress-bar $url -o "$tmptarball" && \ nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum && \ tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \ - mv "$tmpdir" "$NVM_DIR/$VERSION" && \ - rm -f "$tmptarball" + rm "$tmptarball" && \ + mv "$tmpdir" "$NVM_DIR/$VERSION" ) then nvm use $VERSION From b4a9c14d4ef61b4c0c6670f1e5ed633a6cb03a00 Mon Sep 17 00:00:00 2001 From: Matthew Alexander Date: Thu, 24 Oct 2013 18:59:37 -0700 Subject: [PATCH 03/10] Fixed bash error caused by lack of double quotes --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index e4ce9f8..719bf55 100755 --- a/nvm.sh +++ b/nvm.sh @@ -389,7 +389,7 @@ nvm() { if [ -z $VERSION ]; then VERSION=`nvm_version $2` fi - if [ ! -d $NVM_DIR/$VERSION ]; then + if [ ! -d "$NVM_DIR/$VERSION" ]; then echo "$VERSION version is not installed yet" return 1 fi From 7862182d6f86541619405254297074e9eb5af5df Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Thu, 24 Oct 2013 20:09:33 -0700 Subject: [PATCH 04/10] Add -f --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index ad98e0d..fb87879 100755 --- a/nvm.sh +++ b/nvm.sh @@ -262,7 +262,7 @@ nvm() { curl -L -C - --progress-bar $url -o "$tmptarball" && \ nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum && \ tar -xzf "$tmptarball" -C "$tmpdir" --strip-components 1 && \ - rm "$tmptarball" && \ + rm -f "$tmptarball" && \ mv "$tmpdir" "$NVM_DIR/$VERSION" ) then From 5686d9a3bbb3330e5c5d37fce27430176496f431 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Fri, 29 Nov 2013 14:26:12 -0600 Subject: [PATCH 05/10] Addressing comments raised in #171 --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 70f90da..7feee24 100755 --- a/nvm.sh +++ b/nvm.sh @@ -206,7 +206,7 @@ nvm() { echo 'NVM Needs curl to proceed.' >&2; fi - if [ -z "`which shasum`" ]; then + if [ ! `\which shasum` ]; then shasum='sha1sum' fi From aba4346a8633b2185f0b866a4f43a209c660a40a Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Wed, 11 Dec 2013 13:40:56 +0100 Subject: [PATCH 06/10] Universal test of unsetopt command According to http://stackoverflow.com/a/7522866/189431 it should work in "bash, zsh, ksh and sh (as provided by dash)". --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 7feee24..059334b 100755 --- a/nvm.sh +++ b/nvm.sh @@ -9,7 +9,7 @@ # Make zsh glob matching behave same as bash # This fixes the "zsh: no matches found" errors -if [ ! -z "$(which unsetopt 2>/dev/null)" ]; then +if type "unsetopt" > /dev/null; then unsetopt nomatch 2>/dev/null NVM_CD_FLAGS="-q" fi From 037f52a55b724fea4a00c3ea7b9d18cd4576405d Mon Sep 17 00:00:00 2001 From: Adam Hull Date: Wed, 11 Dec 2013 15:23:19 -0800 Subject: [PATCH 07/10] Slurp test unsetopt stderr --- nvm.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nvm.sh b/nvm.sh index 059334b..b645721 100755 --- a/nvm.sh +++ b/nvm.sh @@ -9,7 +9,7 @@ # Make zsh glob matching behave same as bash # This fixes the "zsh: no matches found" errors -if type "unsetopt" > /dev/null; then +if type "unsetopt" > /dev/null 2>&1; then unsetopt nomatch 2>/dev/null NVM_CD_FLAGS="-q" fi From e99fc43ab236a321a65b8bb9b267cb3ea2d4e62f Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Thu, 12 Dec 2013 10:46:40 +0100 Subject: [PATCH 08/10] helper method for testing existence of commands --- nvm.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/nvm.sh b/nvm.sh index b645721..f59c99f 100755 --- a/nvm.sh +++ b/nvm.sh @@ -7,9 +7,14 @@ # Implemented by Tim Caswell # with much bash help from Matthew Ranney +has() { + type "$1" > /dev/null 2>&1 + return $? +} + # Make zsh glob matching behave same as bash # This fixes the "zsh: no matches found" errors -if type "unsetopt" > /dev/null 2>&1; then +if has "unsetopt"; then unsetopt nomatch 2>/dev/null NVM_CD_FLAGS="-q" fi @@ -20,7 +25,7 @@ if [ ! -d "$NVM_DIR" ]; then fi nvm_set_nullglob() { - if type setopt > /dev/null 2>&1; then + if has "setopt"; then # Zsh setopt NULL_GLOB else @@ -202,11 +207,11 @@ nvm() { local shasum='shasum' local nobinary - if [ ! `\which curl` ]; then + if ! has "curl"; then echo 'NVM Needs curl to proceed.' >&2; fi - if [ ! `\which shasum` ]; then + if ! has "shasum"; then shasum='sha1sum' fi @@ -306,7 +311,7 @@ nvm() { ) then nvm use $VERSION - if ! which npm ; then + if ! has "npm" ; then echo "Installing npm..." if [[ "`expr match $VERSION '\(^v0\.1\.\)'`" != '' ]]; then echo "npm requires node v0.2.3 or higher" From 56e32888ea6e93de1befbda688f9b5ee56c6e620 Mon Sep 17 00:00:00 2001 From: "D. Stuart Freeman" Date: Thu, 12 Dec 2013 10:52:43 -0500 Subject: [PATCH 09/10] fix copy-packages --- nvm.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nvm.sh b/nvm.sh index f59c99f..45876ba 100755 --- a/nvm.sh +++ b/nvm.sh @@ -484,9 +484,10 @@ nvm() { nvm help return fi - VERSION=`nvm_version $2` - ROOT=`nvm use $VERSION && npm -g root` - INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` + local VERSION=`nvm_version $2` + local ROOT=`nvm use $VERSION && npm -g root` + local ROOTDEPTH=$((`echo $ROOT | sed 's/[^\/]//g'|wc -m` -1)) + local INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f $(($ROOTDEPTH + 2)) | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` npm install -g $INSTALLS ;; "clear-cache" ) From 94fff5c923b57d7d14a4bcf9e782223825f21ac7 Mon Sep 17 00:00:00 2001 From: Marcin Jekot Date: Sat, 14 Dec 2013 01:10:45 +0200 Subject: [PATCH 10/10] fix copy-packages in zsh (without breaking sh and bash) --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index f59c99f..5c2cce5 100755 --- a/nvm.sh +++ b/nvm.sh @@ -486,8 +486,8 @@ nvm() { fi VERSION=`nvm_version $2` ROOT=`nvm use $VERSION && npm -g root` - INSTALLS=`nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` - npm install -g $INSTALLS + INSTALLS=( `nvm use $VERSION > /dev/null && npm -g -p ll | \grep "$ROOT\/[^/]\+$" | cut -d '/' -f 8 | cut -d ":" -f 2 | \grep -v npm | tr "\n" " "` ) + npm install -g ${INSTALLS[@]} ;; "clear-cache" ) rm -f $NVM_DIR/v* 2>/dev/null