2020-10-15 04:56:18 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
|
2021-03-03 20:23:07 +01:00
|
|
|
version=3.2.2
|
2020-10-15 04:56:18 +02:00
|
|
|
binary="shfmt_v${version}_linux_amd64"
|
2021-03-03 20:23:07 +01:00
|
|
|
sha256=3a32a69286a19491a81fcd854154f0d886c379ff28d99e32d5594490b8bbef4b
|
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"
|
2020-12-09 23:33:24 +01:00
|
|
|
wget -nv "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
|