From 62dec723946ed371185c027f0e4c5763a4808dbe Mon Sep 17 00:00:00 2001 From: Max Zhao Date: Wed, 21 Aug 2013 00:27:10 +0800 Subject: [PATCH] Fixed curl silently ignoring 302 redirections Under certain network environments, due to poor implementation of file download caches (immoral Chinese ISP), the direct download of Node.js packages (http://nodejs.org/dist/node-$VERSION.tar.gz) will be redirected to alternative urls using 302 redirections, which are not handled by `curl --process-bar` by default. Instead, curl will "fail" silently without creating any output file or error exitcode. (Tested under Ubuntu 12.04 Desktop) Fixed by adding "-L" switches to the curl commands responsible for downloading the binary and source node.js packages. --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index e85bfc8..dc44f2d 100755 --- a/nvm.sh +++ b/nvm.sh @@ -258,7 +258,7 @@ nvm() { local tmptarball="$tmpdir/node-${t}.tar.gz" if ( mkdir -p "$tmpdir" && \ - curl -C - --progress-bar $url -o "$tmptarball" && \ + 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" && \ @@ -294,7 +294,7 @@ nvm() { if ( [ ! -z $tarball ] && \ mkdir -p "$tmpdir" && \ - curl --progress-bar $tarball -o "$tmptarball" && \ + curl -L --progress-bar $tarball -o "$tmptarball" && \ if [ "$sum" = "" ]; then : ; else nvm_checksum `${shasum} "$tmptarball" | awk '{print $1}'` $sum; fi && \ tar -xzf "$tmptarball" -C "$tmpdir" && \ cd "$tmpdir/node-$VERSION" && \