zulip/tools/setup/install-shfmt

22 lines
544 B
Bash
Executable File

#!/usr/bin/env bash
set -eu
version=3.2.2
binary="shfmt_v${version}_linux_amd64"
sha256=3a32a69286a19491a81fcd854154f0d886c379ff28d99e32d5594490b8bbef4b
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"
wget -nv "https://github.com/mvdan/sh/releases/download/v$version/$binary"
sha256sum -c <<<"$sha256 $binary"
chmod +x "$binary"
mv "$binary" /usr/local/bin/shfmt
check_version
fi