2020-10-15 04:56:18 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
|
|
|
2021-03-26 00:58:29 +01:00
|
|
|
version=3.2.4
|
2021-05-27 09:16:55 +02:00
|
|
|
arch="$(uname -m)"
|
|
|
|
|
|
|
|
case $arch in
|
|
|
|
"x86_64")
|
|
|
|
binary="shfmt_v${version}_linux_amd64"
|
|
|
|
sha256=3f5a47f8fec27fae3e06d611559a2063f5d27e4b9501171dde9959b8c60a3538
|
|
|
|
;;
|
|
|
|
|
|
|
|
"aarch64")
|
|
|
|
binary="shfmt_v${version}_linux_arm64"
|
|
|
|
sha256=6474d9cc08a1c9fe2ef4be7a004951998e3067d46cf55a011ddd5ff7bfab3de6
|
|
|
|
;;
|
|
|
|
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"
|
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
|