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

clipdel: add -F to match literal instead of regex #229

Merged
merged 2 commits into from
Nov 10, 2024

Conversation

N-R-K
Copy link
Contributor

@N-R-K N-R-K commented Jun 23, 2024

this adds an -F flag similar to grep to allow matching literals instead of a regex.

useful in scripting context where the script has a literal line to match against. using -F avoids having to escape troublesome regex characters.

src/clipdel.c Outdated
struct clipdel_state *state = private;
int ret = regexec(&state->rgx, line, 0, NULL, 0);
int ret = state->literal_match
Copy link
Owner

Choose a reason for hiding this comment

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

patch looks good, my only thought is that the nested ternary isn't the easiest to read. maybe just do it in two if branches? then you don't need to coerce to REG_NOMATCH, too.

this adds an -F flag similar to grep to allow matching literals
instead of a regex.

useful in scripting context where the script has a literal line
to match against. using -F avoids having to escape troublesome
regex characters.
@cdown
Copy link
Owner

cdown commented Nov 9, 2024

Oh, and sorry, could you add a test to tests/x_integration_tests? :-)

@cdown
Copy link
Owner

cdown commented Nov 10, 2024

Looks great, thank you!

@cdown cdown merged commit 68ae70c into cdown:develop Nov 10, 2024
1 check passed
@N-R-K
Copy link
Contributor Author

N-R-K commented Nov 10, 2024

I had to change the shebang to /bin/bash since /usr/bin/bash doesn't exist on my system, but then I noticed that I don't have xsel installed currently either. I added a test case, let's see if it passes the CI :)

@N-R-K N-R-K deleted the literal-clipdel branch November 10, 2024 00:37
@cdown
Copy link
Owner

cdown commented Nov 10, 2024

oh, that path is wrong, it should be /usr/bin/env bash. let me fix that. thanks!

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