Fix a couple crashing cases by throwing exceptions instead. #146
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 #93. Fixes #99.
Throwing an exception from
$&readwhen getting a null byte is kind of weak, but it's strictly better than crashing. In the future I expect we can figure out a way to actually handle null bytes intelligently, but there are a few options there and none of them are the obviously-best one.The error-handling for
writes is also a little sketchy; half the time we ignore the error fromfprint_flush, assuming that if there are any problems, the finalflushwill run into them too and we'll handle them then. Also, in many cases I expect that if stderr is closed or broken, the shell with this change will throw exceptions into exiting (without printing anything), which overall isn't much more helpful than its current behavior of just quietlyexit(2)ing. I think it's still better, though, given the likelihood ofunwind-protects and other cleanup code that deserves to run.For cases where a specific command (or code fragment) is configured into some weird output like
echo >[1=], using exceptions forwriteerrors is a clear win.