Instead of having to handle all possible outcomes, we propose to refactor os::shell() as follows:
where the returned string is stdout and, should the program be signaled, or exit with a non-zero exit code, we will simply return a Failure with an error message that will encapsulate both the returned/signaled state, and, possibly stderr.
And some test driven development:
Alternatively, the caller can ask to have stderr conflated with stdout:
However, stderr will be ignored by default:
An analysis of existing usage shows that in almost all cases, the caller only cares if not error; in fact, the actual exit code is read only once, and even then, in a test case.
We believe this will simplify the API to the caller, and will significantly reduce the length and complexity at the calling sites (<6 LOC against the current 20+).