2018-12-18 02:08:53 +01:00
|
|
|
#!/usr/bin/env bash
|
2018-08-03 02:09:42 +02:00
|
|
|
set -eu
|
|
|
|
|
2023-01-04 21:11:33 +01:00
|
|
|
version=0.9.0
|
2021-05-26 19:07:39 +02:00
|
|
|
arch="$(uname -m)"
|
|
|
|
tarball="shellcheck-v$version.linux.$arch.tar.xz"
|
|
|
|
declare -A sha256=(
|
2023-01-04 21:11:33 +01:00
|
|
|
[aarch64]=179c579ef3481317d130adebede74a34dbbc2df961a70916dd4039ebf0735fae
|
|
|
|
[x86_64]=700324c6dd0ebea0117591c6cc9d7350d9c7c5c287acbad7630fa17b1d4d9e2f
|
2021-05-26 19:07:39 +02:00
|
|
|
)
|
2018-08-03 02:09:42 +02:00
|
|
|
|
2020-10-15 04:55:57 +02:00
|
|
|
check_version() {
|
2022-11-03 18:15:10 +01:00
|
|
|
out="$(shellcheck --version)" && [[ "$out" = *"
|
2018-08-03 02:09:42 +02:00
|
|
|
version: $version
|
2020-04-22 05:09:57 +02:00
|
|
|
"* ]]
|
|
|
|
}
|
|
|
|
|
2022-11-03 18:15:10 +01:00
|
|
|
if ! check_version 2>/dev/null; then
|
2023-05-10 20:32:00 +02:00
|
|
|
set -x
|
2018-08-03 02:09:42 +02:00
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
trap 'rm -r "$tmpdir"' EXIT
|
|
|
|
cd "$tmpdir"
|
2022-11-07 22:50:24 +01:00
|
|
|
curl -fLO --retry 3 "https://github.com/koalaman/shellcheck/releases/download/v$version/$tarball"
|
2021-05-26 19:07:39 +02:00
|
|
|
sha256sum -c <<<"${sha256[$arch]} $tarball"
|
2020-03-31 21:29:25 +02:00
|
|
|
tar -xJf "$tarball" --no-same-owner --strip-components=1 -C /usr/local/bin "shellcheck-v$version/shellcheck"
|
2020-04-22 05:09:57 +02:00
|
|
|
check_version
|
2018-08-03 02:09:42 +02:00
|
|
|
fi
|