From 9d10f94380060caa62b3bd47f12399688b400fff Mon Sep 17 00:00:00 2001 From: zowoq <59103226+zowoq@users.noreply.github.com> Date: Fri, 5 Aug 2022 13:53:18 +1000 Subject: [PATCH] go: print-hashes script - convert to nix-shell - shellcheck / shfmt fixes --- pkgs/development/compilers/go/print-hashes.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/go/print-hashes.sh b/pkgs/development/compilers/go/print-hashes.sh index f095b67c627b..ed3e62b941b8 100755 --- a/pkgs/development/compilers/go/print-hashes.sh +++ b/pkgs/development/compilers/go/print-hashes.sh @@ -1,15 +1,16 @@ -#!/usr/bin/env bash +#!/usr/bin/env nix-shell +#! nix-shell -i bash -p curl jq +# shellcheck shell=bash set -euo pipefail BASEURL=https://go.dev/dl/ VERSION=${1:-} -if [[ -z $VERSION ]] -then - echo "No version supplied" - exit -1 +if [[ -z ${VERSION} ]]; then + echo "No version supplied" + exit 1 fi -curl -s "${BASEURL}?mode=json&include=all" | \ - jq '.[] | select(.version == "go'${VERSION}'")' | \ - jq -r '.files[] | select(.kind == "archive" and (.os == "linux" or .os == "darwin")) | (.os + "-" + .arch + " = \"" + .sha256 + "\";")' +curl -s "${BASEURL}?mode=json&include=all" | + jq '.[] | select(.version == "go'"${VERSION}"'")' | + jq -r '.files[] | select(.kind == "archive" and (.os == "linux" or .os == "darwin")) | (.os + "-" + .arch + " = \"" + .sha256 + "\";")'