fix(record): guard empty ${adb_args[@]} so device_record stop survives macOS bash 3.2 (#374)#375
Merged
Merged
Conversation
…vives on macOS bash 3.2 (#374) record_proof.sh cmd_stop expanded an empty `adb_args` array unguarded in the Android branch; under `set -euo pipefail` on bash 3.2 (the macOS default /bin/bash) that aborts with `adb_args[@]: unbound variable` before the pull/convert, breaking recording finalize — and a leftover Android .pid made even iOS stops crash. Apply the `+`-default guard already used at the saved_paths site to all three expansions. Regression-guarded by a static invariant test (CI-effective on bash 5.x) plus a behavioral reproduction gated to bash < 4.4. Found while device-verifying #282. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #374.
What
device_record action=stopaborted on macOS with:cmd_stop's Android branch declareslocal -a adb_args=()and only fills it when a.serialsidecar exists. In the single-device casecmd_startrm's that sidecar, soadb_argsstays empty — and underset -euo pipefailon bash 3.2 (the macOS default/bin/bash) expanding an empty array as"${adb_args[@]}"is an unbound-variable error, aborting the stop before the pull/convert. Becausecmd_stoploops over all${PID_PREFIX}-*.pidsidecars, a leftover Android.pidmade even iOS stops crash.Bash ≥ 4.4 removed that behavior, so it never reproduced on
ubuntu-latestCI — which is why the full unit suite never caught it.Fix
Apply the
+-default guard already used in the same file (saved_pathsat what was line 249) to the threeadb_argsexpansions:adb "${adb_args[@]+"${adb_args[@]}"}" …+3 −3inscripts/record_proof.sh.Tests (
gh-374-record-proof-adb-args-unbound.test.js)Two layers, because the runtime crash is bash-version-specific:
adb "${adb_args[@]}"remains and the 3 guarded forms are present. Verified it flips to fail when the guard is reverted.oxlint+oxfmt --check: clean.Device-verified
Found while device-verifying #282 on a live Android emulator + iOS sim. After the fix, Android
stopfinalized a 38 s MP4 where it crashed twice before; iOS unaffected. (The #282 investigation separately confirmed #282 was already mitigated — closed as such.)🤖 Generated with Claude Code