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 on invalid regexps #709

Closed
Wilfred opened this issue Dec 6, 2017 · 12 comments
Closed

Suggest --fixed-strings on invalid regexps #709

Wilfred opened this issue Dec 6, 2017 · 12 comments
Labels
enhancement An enhancement to the functionality of the software.

Comments

@Wilfred
Copy link
Contributor

Wilfred commented Dec 6, 2017

$ rg "foo("
Error parsing regex near 'foo(' at character offset 3: Unclosed parenthesis.

I think ripgrep should suggest the --fixed-strings argument if there's a regex syntax error.

@BurntSushi
Copy link
Owner

Hmmmm... I think I'd be OK with that.

@BurntSushi BurntSushi added the enhancement An enhancement to the functionality of the software. label Dec 6, 2017
@balajisivaraman
Copy link
Contributor

I can pick this one up next.

One question though: Do we still want the error generated by the regex lib to be propagated all the way to the command line? Or are OK with replacing that with a generic error such as: "Syntax error encountered while parsing provided regex. Please recheck. Note: Perhaps you meant to use --fixed-strings instead."

I can think of a relatively straightforward, easy-to-implement fix if we're OK with the latter.

@erikrw
Copy link

erikrw commented Jan 1, 2018

I would suggest regex error details to be shown to the user. grep, ack, and ag also give details about regex errors.

@BurntSushi
Copy link
Owner

@balajisivaraman We definitely want to surface the syntax error.

@balajisivaraman
Copy link
Contributor

Can this be closed with the merging of #727?

@BurntSushi
Copy link
Owner

@balajisivaraman Yup! Thanks.

@wsdjeg
Copy link

wsdjeg commented Feb 1, 2018

@BurntSushi does --fixed-strings means auto fixe regex? I mean if the regex has no errors, just use it as regex.

@BurntSushi
Copy link
Owner

@wsdjeg I don't understand your question or your suggestion. Could you please elaborate? Please include examples.

@BurntSushi
Copy link
Owner

@wsdjeg Also, have you read the documentation?

    -F, --fixed-strings                     
            Treat the pattern as a literal string instead of a regular expression. When this flag is
            used, special regular expression meta characters such as (){}*+. do not need to be
            escaped.

@wsdjeg
Copy link

wsdjeg commented Feb 1, 2018

@BurntSushi I have read it, I just create a grep plugin , and using rg as backgroud tool. search the user's input.

I hope I auto detect if the user is input a right expression. that means, it will be better there is an option --auto-fixed-string. if there is error in such expression, treat it as fixed string. otherwise use it as regex.

here is an gif:

2018-02-01-22-05-15

@BurntSushi
Copy link
Owner

@wsdjeg That seems like a distinct feature request that is completely orthogonal to this issue. Please open a new issue.

@wsdjeg
Copy link

wsdjeg commented Feb 1, 2018

Ok, and thanks for this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement to the functionality of the software.
Projects
None yet
Development

No branches or pull requests

5 participants