Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

ci: check an archive's listing without piping it into grep -q

Kelvinc1bc4787d423
diff --git a/cli/scripts/build-managed-grid.sh b/cli/scripts/build-managed-grid.sh
index 86f509f63..bf249a400 100755
--- a/cli/scripts/build-managed-grid.sh
+++ b/cli/scripts/build-managed-grid.sh
@@ -79,7 +79,8 @@ case "$PLATFORM" in
echo ">> fetching $ASSET from $GRID_RELEASE_BASE"
fetch "$GRID_RELEASE_BASE/$ASSET" "$WORK/$ASSET"
fetch "$GRID_RELEASE_BASE/SHA256SUMS" "$WORK/SHA256SUMS"
- want="$(grep -E "[[:space:]]${ASSET}\$" "$WORK/SHA256SUMS" | awk '{print $1}' | head -1)"
+ # One process, no pipe: under `pipefail` a `head -1` closing the pipe early would fail the line.
+ want="$(awk -v asset="$ASSET" '$2 == asset { print $1; exit }' "$WORK/SHA256SUMS")"
[ -n "$want" ] || { echo "error: the release's SHA256SUMS names no $ASSET" >&2; exit 1; }
got="$(sha256_of "$WORK/$ASSET")"
[ "$got" = "$want" ] || {
@@ -112,7 +113,7 @@ fetch "$GRID_RAW_BASE/LICENSE" "$STAGE/LICENSE.grid"
if [ "$(host_platform)" = "$PLATFORM" ]; then
answered="$(GRID_NO_UPDATE_CHECK=1 "$STAGE/bin/grid" --version 2>&1 || true)"
# The whole line, not a substring: `0.3.4` is inside `0.3.47`.
- if printf '%s\n' "$answered" | grep -qxE "grid ${VERSION//./\\.}"; then
+ if grep -qxE "grid ${VERSION//./\\.}" <<< "$answered"; then
echo ">> smoke: $answered"
else
echo "error: $STAGE/bin/grid --version answered '$answered', not 'grid $VERSION'" >&2
diff --git a/desktop/scripts/publish-managed-grid-runtime.sh b/desktop/scripts/publish-managed-grid-runtime.sh
index a7ceefa1c..51274ab88 100755
--- a/desktop/scripts/publish-managed-grid-runtime.sh
+++ b/desktop/scripts/publish-managed-grid-runtime.sh
@@ -78,7 +78,11 @@ for platform in $PLATFORMS; do
archive_path="$ARCHIVES_DIR/$archive"
[[ -f "$archive_path" ]] || { echo "error: missing $archive_path" >&2; exit 1; }
root="grid-${VERSION}-${platform}"
- tar -tzf "$archive_path" | grep -qx "${root}/bin/grid" || {
+ # The listing is captured, not piped into `grep -q`: under `pipefail`, grep closing the pipe as soon
+ # as it matches gives tar a write error, and the whole pipeline — and this check — fails on an
+ # archive that is fine. It did, on the first publish, on the fourth and largest archive.
+ listing="$(tar -tzf "$archive_path")"
+ grep -qx "${root}/bin/grid" <<< "$listing" || {
echo "error: $archive has no ${root}/bin/grid" >&2
exit 1
}
diff --git a/desktop/scripts/publish-managed-tmux-runtime.sh b/desktop/scripts/publish-managed-tmux-runtime.sh
index cf9be4929..a26434a04 100755
--- a/desktop/scripts/publish-managed-tmux-runtime.sh
+++ b/desktop/scripts/publish-managed-tmux-runtime.sh
@@ -65,7 +65,10 @@ for platform in darwin-arm64 darwin-x64; do
archive_path="$ARCHIVES_DIR/$archive"
[[ -f "$archive_path" ]] || { echo "error: missing $archive_path" >&2; exit 1; }
root="tmux-${VERSION}-${platform}"
- tar -tzf "$archive_path" | grep -qx "${root}/bin/tmux" || {
+ # Captured, not piped into `grep -q`: under `pipefail` grep closing the pipe early fails the whole
+ # pipeline on a fine archive — seen on the grid publisher's larger archives, latent here.
+ listing="$(tar -tzf "$archive_path")"
+ grep -qx "${root}/bin/tmux" <<< "$listing" || {
echo "error: $archive has no ${root}/bin/tmux" >&2
exit 1
}