Handle errors with pipe instead of process substitution

This commit is contained in:
Jean-François Roche 2022-12-13 10:42:30 +01:00
parent 1332d9af38
commit 5ba328cfe8
No known key found for this signature in database
GPG key ID: D1D09DE169EA19A0

View file

@ -2,6 +2,7 @@
#!nix-shell -p nixos-generators -p nix -p coreutils -p bash -p gh -i bash
# shellcheck shell=bash
set -xeuo pipefail
shopt -s lastpipe
build_netboot_image() {
declare -r tag=$1 arch=$2 tmp=$3
@ -38,15 +39,11 @@ main() {
declare -r tag=${1:-nixos-unstable} arch=${2:-x86_64-linux}
tmp="$(mktemp -d)"
trap 'rm -rf -- "$tmp"' EXIT
readarray -t assets < <(
(
build_kexec_installer "$tag" "$arch" "$tmp"
build_kexec_bundle "$tag" "$arch" "$tmp"
build_netboot_image "$tag" "$arch" "$tmp"
)
if [ ! "${#assets[@]}" -eq "3" ]; then
echo "Missing build asset"
exit 1
fi
) | readarray -t assets
for asset in "${assets[@]}"; do
pushd "$(dirname "$asset")"
sha256sum "$(basename "$asset")" >> "$TMP/sha256sums"