Skip to content

Commit f6dca82

Browse files
fix(scripts): make fetch-binaries.sh macOS-compatible (drop bash-4 mapfile)
macOS ships bash 3.2 where mapfile is unavailable, so the macOS release job failed with exit 127. Replace mapfile with a portable temp-file + while-read loop. Co-authored-by: openhands <openhands@all-hands.dev>
1 parent ac0a9ad commit f6dca82

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

‎scripts/fetch-binaries.sh‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ sha256_of() {
7272
}
7373

7474
tmp_checksums="$(mktemp)"
75-
trap 'rm -f "$tmp_checksums"' EXIT
75+
tmp_entries="$(mktemp)"
76+
trap 'rm -f "$tmp_checksums" "$tmp_entries"' EXIT
7677

7778
echo "Fetching checksums from $CHECKSUMS_URL"
7879
if ! download "$CHECKSUMS_URL" "$tmp_checksums"; then
@@ -86,18 +87,21 @@ mkdir -p "$DEST"
8687
arch_filter="[^/]+"
8788
[[ -n "$ARCH" ]] && arch_filter="$ARCH"
8889

89-
mapfile -t entries < <(tr -d '\r' < "$tmp_checksums" \
90+
# Write matches to a temp file (avoids bash-4 `mapfile`, unavailable on macOS).
91+
tr -d '\r' < "$tmp_checksums" \
9092
| awk -v os="$OS" -v arch="$arch_filter" \
91-
'$2 ~ "^"os"/"arch"/" { print $1" "$2 }')
93+
'$2 ~ "^"os"/"arch"/" { print $1" "$2 }' > "$tmp_entries"
9294

93-
if [[ ${#entries[@]} -eq 0 ]]; then
95+
count=$(wc -l < "$tmp_entries" | tr -d ' ')
96+
if [ "$count" -eq 0 ]; then
9497
echo "Error: no binaries found for $OS/${ARCH:-*}" >&2
9598
exit 2
9699
fi
97100

98-
echo "Fetching ${#entries[@]} binaries for $OS/${ARCH:-*} into $DEST"
101+
echo "Fetching $count binaries for $OS/${ARCH:-*} into $DEST"
99102

100-
for entry in "${entries[@]}"; do
103+
while IFS= read -r entry; do
104+
[ -z "$entry" ] && continue
101105
expected_sha="${entry%% *}"
102106
rel_path="${entry##* }"
103107
filename="$(basename "$rel_path")"
@@ -124,6 +128,6 @@ for entry in "${entries[@]}"; do
124128
chmod +x "$out"
125129
fi
126130
echo " ✓ $filename"
127-
done
131+
done < "$tmp_entries"
128132

129-
echo "Done: ${#entries[@]} binaries verified in $DEST"
133+
echo "Done: $count binaries verified in $DEST"

0 commit comments

Comments
 (0)