2020-10-15 04:56:18 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
|
2022-06-02 01:33:00 +02:00
|
|
|
version=3.5.0
|
2021-05-27 09:16:55 +02:00
|
|
|
arch="$(uname -m)"
|
|
|
|
|
|
|
|
case $arch in
|
|
|
|
"x86_64")
|
|
|
|
binary="shfmt_v${version}_linux_amd64"
|
2022-06-02 01:33:00 +02:00
|
|
|
sha256=8feea043364a725dfb69665432aee9e85b84c7f801a70668650e8b15452f6574
|
2021-05-27 09:16:55 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
"aarch64")
|
|
|
|
binary="shfmt_v${version}_linux_arm64"
|
2022-06-02 01:33:00 +02:00
|
|
|
sha256=2dec40f18622873dd3bf84fda17f43a0ae93b5305ead909dc0e91f6479d359c6
|
2021-05-27 09:16:55 +02:00
|
|
|
;;
|
|
|
|
esac
|
2020-10-15 04:56:18 +02:00
|
|
|
|
|
|
|
check_version() {
|
|
|
|
out="$(shfmt --version 2>/dev/null)" && [ "$out" = "v$version" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! check_version; then
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
trap 'rm -r "$tmpdir"' EXIT
|
|
|
|
cd "$tmpdir"
|
2021-07-13 21:00:50 +02:00
|
|
|
curl -fLO "https://github.com/mvdan/sh/releases/download/v$version/$binary"
|
2020-10-15 04:56:18 +02:00
|
|
|
sha256sum -c <<<"$sha256 $binary"
|
|
|
|
chmod +x "$binary"
|
|
|
|
mv "$binary" /usr/local/bin/shfmt
|
|
|
|
check_version
|
|
|
|
fi
|