Fix grammar and print exit code from http client.

This commit is contained in:
Jean Niklas L'orange 2014-08-11 09:59:04 +02:00
parent 26dd8c2074
commit 651370487d

View file

@ -50,11 +50,11 @@ function add_path {
} }
function download_failed_message { function download_failed_message {
echo "Failed to download $1" echo "Failed to download $1 (exit code $2)"
echo "It's possible your HTTP client's certificate store does not have the" echo "It's possible your HTTP client's certificate store does not have the"
echo "correct certificate authority needed. This is often caused by an" echo "correct certificate authority needed. This is often caused by an"
echo "out-of-date version of libssl. It's also possible that you're behind a" echo "out-of-date version of libssl. It's also possible that you're behind a"
echo "firewall haven't yet set HTTP_PROXY and HTTPS_PROXY." echo "firewall and haven't set HTTP_PROXY and HTTPS_PROXY."
} }
function self_install { function self_install {
@ -67,12 +67,13 @@ function self_install {
mkdir -p "$(dirname "$LEIN_JAR")" mkdir -p "$(dirname "$LEIN_JAR")"
LEIN_URL="https://github.com/technomancy/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.jar" LEIN_URL="https://github.com/technomancy/leiningen/releases/download/$LEIN_VERSION/leiningen-$LEIN_VERSION-standalone.jar"
$HTTP_CLIENT "$LEIN_JAR.pending" "$LEIN_URL" $HTTP_CLIENT "$LEIN_JAR.pending" "$LEIN_URL"
if [ $? == 0 ]; then local exit_code=$?
if [ $exit_code == 0 ]; then
# TODO: checksum # TODO: checksum
mv -f "$LEIN_JAR.pending" "$LEIN_JAR" mv -f "$LEIN_JAR.pending" "$LEIN_JAR"
else else
rm "$LEIN_JAR.pending" 2> /dev/null rm "$LEIN_JAR.pending" 2> /dev/null
download_failed_message "$LEIN_URL" download_failed_message "$LEIN_URL" "$exit_code"
exit 1 exit 1
fi fi
} }