Skip to content

Commit

Permalink
Fix the fetch-configlet script, which broke recently (#929)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
coriolinus authored Feb 28, 2020
1 parent 749b8bb commit bf54e82
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions bin/fetch-configlet
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

LATEST=https://github.com/exercism/configlet/releases/latest

OS=$(
Expand All @@ -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/

0 comments on commit bf54e82

Please sign in to comment.