Skip to content

Conversation

@jpco
Copy link
Collaborator

@jpco jpco commented Nov 24, 2024

Fixes #93. Fixes #99.

Throwing an exception from $&read when 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 from fprint_flush, assuming that if there are any problems, the final flush will 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 quietly exit(2)ing. I think it's still better, though, given the likelihood of unwind-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 for write errors is a clear win.

@jpco
Copy link
Collaborator Author

jpco commented Nov 24, 2024

Okay, I guess this test case just spontaneously broke at HEAD (I tried reverting these commits and the test was still broken). That's odd. I commented out the case and will have to follow up later.

@jpco jpco added the bug label Nov 26, 2024
@jpco jpco merged commit 1b134f7 into wryun:master Nov 26, 2024
@jpco jpco deleted the except branch November 26, 2024 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

echo >[1=] kills the shell $&reading a NUL byte crashes the shell

1 participant