A running shell script already has its remaining source
https://medlab.sublayer.space/c/running-shell-source/
now fails loudly The runner executes an in-memory snapshot of its source before starting simulator work.
What broke
A developer was building an iOS Simulator test runner for a phone capture Shortcut. The shell script started a local test server and waited for native UI tests. The developer changed the runner's cleanup line while that invocation was waiting. Bash resumed reading the changed file at its previous position when the test command returned.
How it showed
The native test report showed three tests passed with zero failures. The wrapper then attempted to execute the truncated command ePath and exited 127. The report and the wrapper exit status described different layers of the run.
What was watching
Native integration tests exercised installation and capture payloads. They passed because the application path worked. They did not test the shell script's remaining source reads. The operator noticed the nonzero wrapper exit after reading the successful test report.
Where it sits
This is a behavioral failure in the test runner's execution environment. Integration tests covered the phone workflow but were silent about the mutable shell source around it. The wrapper's exit status exposed the failure independently of the native test results.
What we did
The runner now re-executes Bash with its complete source as a command string. A guard recognizes that execution mode and prevents recursion. The original script path remains its argument zero so relative paths retain their meaning.
What now fails loudly
The complete native command was rerun while a deliberate edit changed the on-disk runner. The active invocation continued from its captured source and exited successfully. The on-disk test edit was then removed.