From bf54e821325cf7ca26e1f008559d27a0d5becd81 Mon Sep 17 00:00:00 2001 From: Peter Goodspeed-Niklaus Date: Fri, 28 Feb 2020 14:29:44 +0100 Subject: [PATCH] Fix the fetch-configlet script, which broke recently (#929) Looks like Github has recently started returning non-uppercased HTTP headers, at least some of the time. This broke the script, which looked for a case-sensitive 'Location' header to find the newest version. This fixes the script such that it no longer cares whether the initial L is capital or not, and if it breaks again in the future, it will give a more informative error. --- bin/fetch-configlet | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/fetch-configlet b/bin/fetch-configlet index 4f64c5b9a..73ad7a015 100755 --- a/bin/fetch-configlet +++ b/bin/fetch-configlet @@ -1,5 +1,7 @@ #!/bin/bash +set -e + LATEST=https://github.com/exercism/configlet/releases/latest OS=$( @@ -26,7 +28,12 @@ case $(uname -m) in echo 64bit;; esac) -VERSION="$(curl --head --silent $LATEST | awk -v FS=/ '/Location:/{print $NF}' | tr -d '\r')" +VERSION="$(curl --head --silent $LATEST | awk -v FS=/ '/[lL]ocation:/{print $NF}' | tr -d '\r')" +if [ -z "$VERSION" ]; then + echo "Latest configlet release could not be determined; aborting" + exit 1 +fi + URL=https://github.com/exercism/configlet/releases/download/$VERSION/configlet-$OS-${ARCH}.tgz -curl -s --location $URL | tar xz -C bin/ +curl -sS --location $URL | tar xz -C bin/