From a7cbfb32e639c35843d472ce86bb2d17d04ec563 Mon Sep 17 00:00:00 2001 From: Cheng Lian Date: Wed, 22 Jul 2015 23:15:10 +0800 Subject: [PATCH 1/2] Supports HTTP/HTTPS redirection --- build/sbt-launch-lib.bash | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build/sbt-launch-lib.bash b/build/sbt-launch-lib.bash index 504be48b358f..89fa0673d612 100755 --- a/build/sbt-launch-lib.bash +++ b/build/sbt-launch-lib.bash @@ -51,7 +51,9 @@ acquire_sbt_jar () { printf "Attempting to fetch sbt\n" JAR_DL="${JAR}.part" if [ $(command -v curl) ]; then - (curl --silent ${URL1} > "${JAR_DL}" || curl --silent ${URL2} > "${JAR_DL}") && mv "${JAR_DL}" "${JAR}" + (curl --location --silent ${URL1} > "${JAR_DL}" ||\ + curl --location --silent ${URL2} > "${JAR_DL}") &&\ + mv "${JAR_DL}" "${JAR}" elif [ $(command -v wget) ]; then (wget --quiet ${URL1} -O "${JAR_DL}" || wget --quiet ${URL2} -O "${JAR_DL}") && mv "${JAR_DL}" "${JAR}" else From fd266ca86d96767afc973ff37383a0abd82796ca Mon Sep 17 00:00:00 2001 From: Cheng Lian Date: Wed, 22 Jul 2015 23:42:02 +0800 Subject: [PATCH 2/2] Uses `--fail' to make curl return non-zero value and remove garbage output when the download fails --- build/sbt-launch-lib.bash | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/build/sbt-launch-lib.bash b/build/sbt-launch-lib.bash index 89fa0673d612..7930a38b9674 100755 --- a/build/sbt-launch-lib.bash +++ b/build/sbt-launch-lib.bash @@ -51,11 +51,13 @@ acquire_sbt_jar () { printf "Attempting to fetch sbt\n" JAR_DL="${JAR}.part" if [ $(command -v curl) ]; then - (curl --location --silent ${URL1} > "${JAR_DL}" ||\ - curl --location --silent ${URL2} > "${JAR_DL}") &&\ - mv "${JAR_DL}" "${JAR}" + (curl --fail --location --silent ${URL1} > "${JAR_DL}" ||\ + (rm -f "${JAR_DL}" && curl --fail --location --silent ${URL2} > "${JAR_DL}")) &&\ + mv "${JAR_DL}" "${JAR}" elif [ $(command -v wget) ]; then - (wget --quiet ${URL1} -O "${JAR_DL}" || wget --quiet ${URL2} -O "${JAR_DL}") && mv "${JAR_DL}" "${JAR}" + (wget --quiet ${URL1} -O "${JAR_DL}" ||\ + (rm -f "${JAR_DL}" && wget --quiet ${URL2} -O "${JAR_DL}")) &&\ + mv "${JAR_DL}" "${JAR}" else printf "You do not have curl or wget installed, please install sbt manually from http://www.scala-sbt.org/\n" exit -1