From 1a08edd94e554174dc52218396e0bd5f5a8a316f Mon Sep 17 00:00:00 2001 From: Kosei Moriyama Date: Sat, 24 Nov 2012 00:05:23 +0900 Subject: [PATCH] support platforms which does not have shasum command use sha1sum command if there is no shasum command --- nvm.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index bc42df2..6d3bed6 100755 --- a/nvm.sh +++ b/nvm.sh @@ -178,11 +178,16 @@ nvm() local url local sum local tarball + local shasum='shasum' if [ ! `which curl` ]; then echo 'NVM Needs curl to proceed.' >&2; fi + if [ ! `which shasum > /dev/null 2>&1` ]; then + shasum='sha1sum' + fi + if [ $# -lt 2 ]; then nvm help return @@ -216,7 +221,7 @@ nvm() mkdir -p "$NVM_DIR/bin/node-${t}" && \ cd "$NVM_DIR/bin" && \ curl -C - --progress-bar $url -o "node-${t}.tar.gz" && \ - nvm_checksum `shasum node-${t}.tar.gz | awk '{print $1}'` $sum && \ + nvm_checksum `${shasum} node-${t}.tar.gz | awk '{print $1}'` $sum && \ tar -xzf "node-${t}.tar.gz" -C "node-${t}" --strip-components 1 && \ mv "node-${t}" "../$VERSION" && \ rm -f "node-${t}.tar.gz" @@ -246,7 +251,7 @@ nvm() mkdir -p "$NVM_DIR/src" && \ cd "$NVM_DIR/src" && \ curl --progress-bar $tarball -o "node-$VERSION.tar.gz" && \ - if [ "$sum" = "" ]; then : ; else nvm_checksum `shasum node-$VERSION.tar.gz | awk '{print $1}'` $sum; fi && \ + if [ "$sum" = "" ]; then : ; else nvm_checksum `${shasum} node-$VERSION.tar.gz | awk '{print $1}'` $sum; fi && \ tar -xzf "node-$VERSION.tar.gz" && \ cd "node-$VERSION" && \ ./configure --prefix="$NVM_DIR/$VERSION" $ADDITIONAL_PARAMETERS && \