#!/bin/bash # Row 77 byte check: render without --copy, base script against candidate, # same tree, same flags. Usage: byte-check.sh # The base script is placed beside the candidate in /scripts for the # run (so both resolve the same REPO and template) and removed afterwards. # Only render runs; nothing installs, reads systemd or starts anything. set -u tree=$1 base=$2 out=$3 mkdir -p "$out" b="$tree/scripts/.webui-service.base.sh" git -C "$tree" show "$base:scripts/webui-service.sh" > "$b" && chmod +x "$b" || exit 1 trap 'rm -f "$b"' EXIT # The base renders its own template; check the template's body is unchanged # apart from the header comment, so the comparison is fair. diff <(git -C "$tree" show "$base:packages/webui/systemd/mosaic-webui.service.in" | grep -v '^#') <(grep -v '^#' "$tree/packages/webui/systemd/mosaic-webui.service.in") > "$out/template-body.diff" && echo "template body: same" || echo "template body: DIFFERS" uid=6f1c0e2a9b8d7c4e5f3a2b1c0d9e8f7a6b5c4d3e2f1a0b9c8d7e6f5a4b3c2d1e n=0 same=0 while IFS= read -r flags; do n=$((n+1)) # shellcheck disable=SC2086 "$b" render $flags 2>&1 | grep -v '^#' > "$out/base-$n.txt"; bs=${PIPESTATUS[0]} # shellcheck disable=SC2086 "$tree/scripts/webui-service.sh" render $flags 2>&1 | grep -v '^#' > "$out/cand-$n.txt"; cs=${PIPESTATUS[0]} if [ "$bs" = "$cs" ] && cmp -s "$out/base-$n.txt" "$out/cand-$n.txt"; then same=$((same+1)); r=same; else r=DIFFERS; fi echo "$n exit $bs/$cs $r: render $flags" done <