-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exit on first EOF from stdin #492
Conversation
per docs, process::exit:
Not sure if this is an issue or not? |
Thanks for bringing this up! I was hoping process::exit was sufficient for this simple case, but I can see the argument for a stricter exit sequence as well. This is also how a BrokenPipe error is handled, so there is a precedent. I'd like to know the maintainer's thoughts as well :). |
Thank you for working on this. Yes, returning an Using Speaking of wrong behavior: it would be great if we could add integration/regression tests for this (see |
Okay, thanks for the input. I'll look into implementing this and include integration tests as well. |
I agree with sharkdp that |
@willcassella I added the Result here to handle |
I think it should be fine to handle the error with |
26e0b47
to
9d4fb22
Compare
Okay, I created a new ErrorKind variant and essentially just ignore it - would any extra actions need to be taken? The behavior is now correct with multiple input files, e.g. I haven't figured out how to emulate a CTRL-D for an integration test yet. |
9d4fb22
to
8289aa9
Compare
src/controller.rs
Outdated
@@ -45,7 +45,10 @@ impl<'b> Controller<'b> { | |||
match input_file.get_reader(&stdin) { | |||
Err(error) => { | |||
handle_error(&error); | |||
no_errors = false; | |||
match error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of matching on ErrorKind::ImmediateEOF
here and in handle_error
, could we also move the handle_error
call into the _ =>
branch?
match error {
Error(ErrorKind::ImmediateEOF, _) => (),
_ => {
handle_error(&error);
no_errors = false
},
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - that did seem redundant. I backed it up even further and just matched the Result
against the Err(Error(ErrorKind::ImmediateEOF, _))
, if that works for you.
You are right, that's probably very tricky. I'd like to have some tests where we check that |
Makes sense. I can write that up. |
…F was found before delimeter.
8289aa9
to
31efbc8
Compare
Thank you for the update! |
Sorry I didn't notice that, I got distracted by how cool Thanks for fixing this! |
Addresses #477.