From 679c71650f3096220feead1c4ad6ae6d4bc5e38d Mon Sep 17 00:00:00 2001 From: Marcin Jekot Date: Wed, 18 Dec 2013 17:21:00 +0200 Subject: [PATCH] fix copy-packages in zsh fixes #299, finally, using the local var syntax --- nvm.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 81920f5..8639288 100755 --- a/nvm.sh +++ b/nvm.sh @@ -492,9 +492,13 @@ nvm() { return fi local VERSION=`nvm_version $2` - local ROOT=`nvm use $VERSION && npm -g root` + local ROOT=`(nvm use $VERSION && npm -g root) | tail -n1` 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" " "` ) + + # declare local INSTALLS first, otherwise it doesn't work in zsh + local INSTALLS + 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" )