Files
zulip/tools/setup/install-shfmt
Anders Kaseorg 29fb68ebcc install-shfmt: Upgrade shfmt from 3.10.0 to 3.11.0.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-03-14 18:32:23 -07:00

34 lines
801 B
Bash
Executable File

#!/usr/bin/env bash
set -eu
version=3.11.0
arch="$(uname -m)"
case $arch in
"x86_64")
binary="shfmt_v${version}_linux_amd64"
sha256=1904ec6bac715c1d05cd7f6612eec8f67a625c3749cb327e5bfb4127d09035ff
;;
"aarch64")
binary="shfmt_v${version}_linux_arm64"
sha256=b3976121710fd4b12bf641b0a7fb2686da598fb0da9f148c641b61b54cfa3407
;;
esac
check_version() {
out="$(shfmt --version)" && [ "$out" = "v$version" ]
}
if ! check_version 2>/dev/null; then
set -x
tmpdir="$(mktemp -d)"
trap 'rm -r "$tmpdir"' EXIT
cd "$tmpdir"
curl -fLO --retry 3 "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