Skip to content
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

Suggest --fixed-strings flag in case of regex parse error (closes #709) #727

Merged
merged 1 commit into from
Jan 1, 2018
Merged

Suggest --fixed-strings flag in case of regex parse error (closes #709) #727

merged 1 commit into from
Jan 1, 2018

Conversation

balajisivaraman
Copy link
Contributor

This is the most straightforward fix I could think of for #709. Please let me know if it could be improved upon.

Thanks!

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Couldn't have done it better myself. Just left a few nits. :)

src/args.rs Outdated
GrepError::Regex(err) => {
let s = format!("{}\nIf you wanted to treat the \
string within double quotes as a literal string, you \
should pass the --fixed-strings flag.", err.to_string());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would just write, \n(Hint: try the --fixed-strings flag to search a literal.)

tests/tests.rs Outdated

let output = cmd.output().unwrap();
let err = String::from_utf8_lossy(&output.stderr);
let expected = "If you wanted to treat the string within double quotes as a literal string, you should pass the --fixed-strings flag.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find a way to wrap this to 79 columns. :)

Also, I'd probably just check that the error message mentions --fixed-strings, otherwise the test will probably be unusefully brittle.

@balajisivaraman
Copy link
Contributor Author

Done. And yeah, I kinda felt iffy about that test, thanks for suggesting a better one. :-)

Copy link
Owner

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet! Thanks!

@BurntSushi BurntSushi merged commit 14779ed into BurntSushi:master Jan 1, 2018
@balajisivaraman balajisivaraman deleted the fix_709 branch January 1, 2018 16:29
@balajisivaraman
Copy link
Contributor Author

Just a heads up: I just noticed that the commit message for this merge says fixes 727 (the PR No), instead of 709.

@BurntSushi
Copy link
Owner

@balajisivaraman Whoops. I goofed in the commit message. Ah well. I ain't force pushing master, so we'll just have to live with it. :) Thanks for the heads up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants