carlos / platform Public

20-cross: fail the size check when the binary cannot be measured

The pipeline masked a wc failure, leaving size empty and the step green.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 0e6246498ff28ad54fec10d152e739c6997aa706 parent e0d2d50
1 file changed, +9 −1
  • .amadan/ci.d/20-cross@5 +9 −1
diff --git a/.amadan/ci.d/20-cross@5 b/.amadan/ci.d/20-cross@5
index c6b3b40cc..60fe5870a 100755
--- a/.amadan/ci.d/20-cross@5
+++ b/.amadan/ci.d/20-cross@5
@@ -85,7 +85,15 @@ if [ "$GOOS/$GOARCH" = "linux/arm64" ]; then
size_dir=$(mktemp -d)
trap 'rm -rf "$size_dir"' EXIT
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-s -w" -o "$size_dir/carlos" .
- size=$(wc -c <"$size_dir/carlos" | tr -d ' ')
+ # No pipeline here: `wc | tr` would report tr's exit status, an unreadable
+ # binary would leave size empty, and the comparison below would error
+ # inside `if` and let the step pass. Fail on the read, then on anything
+ # that is not a number (BSD wc pads with spaces, which $(( )) accepts).
+ size=$(wc -c <"$size_dir/carlos") || { echo "cannot read the built binary $size_dir/carlos"; exit 1; }
+ case $size in
+ '' | *[!0-9' ']*) echo "could not measure the linux/arm64 binary (wc said '$size')"; exit 1 ;;
+ esac
+ size=$((size))
echo "linux/arm64 carlos binary: $size bytes (ceiling $max_bytes)"
if [ "$size" -gt "$max_bytes" ]; then
echo "the linux/arm64 binary is $size bytes, over the $max_bytes ceiling."