Skip to content

Commit c4f360d

Browse files
committed
Fix fetch-configlet bash script for windows
Sync with upstream exercism/configlet#156 * This correctly sets the OS and EXTension when on windows, even when in bash (or a different bourne-shell). * Additionally this uses unzip if the extension is zip, as tar will correctly say the zip is not a tar. `unzip` does not allow for piping, so a temporary file is created.
1 parent 6b48a1c commit c4f360d

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

bin/fetch-configlet

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/bin/bash
22

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

@@ -10,10 +10,20 @@ case $(uname) in
1010
echo "linux";;
1111
(Windows*)
1212
echo "windows";;
13+
(MINGW*)
14+
echo "windows";;
1315
(*)
1416
echo "linux";;
1517
esac)
1618
19+
EXT=$(
20+
case $OS in
21+
(windows*)
22+
echo "zip";;
23+
(*)
24+
echo "tgz";;
25+
esac)
26+
1727
ARCH=$(
1828
case $(uname -m) in
1929
(*64*)
@@ -26,7 +36,15 @@ case $(uname -m) in
2636
echo 64bit;;
2737
esac)
2838
29-
VERSION="$(curl --head --silent $LATEST | awk -v FS=/ '/Location:/{print $NF}' | tr -d '\r')"
30-
URL=https://github.com/exercism/configlet/releases/download/$VERSION/configlet-$OS-${ARCH}.tgz
3139
32-
curl -s --location $URL | tar xz -C bin/
40+
VERSION="$(curl --silent --head $LATEST | awk -v FS=/ '/Location:/{print $NF}' | tr -d '\r')"
41+
URL=https://github.com/exercism/configlet/releases/download/$VERSION/configlet-$OS-${ARCH}.$EXT
42+
43+
case $EXT in
44+
(*zip)
45+
curl -s --location $URL -o bin/latest-configlet.zip
46+
unzip bin/latest-configlet.zip -d bin/
47+
rm bin/latest-configlet.zip;;
48+
(*)
49+
curl -s --location $URL | tar xz -C bin/;;
50+
esac

0 commit comments

Comments
 (0)