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

pcre2grep: add --posix-pattern-file for compatibility with other grep #428

Merged
merged 1 commit into from
Jun 18, 2024

Conversation

carenas
Copy link
Contributor

@carenas carenas commented Jun 16, 2024

Historically, pcre2grep removes empty lines of the file provided with the -f option and trims trailing space characters on each line, this means (among other differences) that it is not possible to provide an empty pattern through it and the following inconsistency is observed (comparing against GNU/*NIX grep):

% echo "" > input && cp input pat
% grep -qf pat input; echo $?
0
% ggrep -qf pat input; echo $?
0
% pcre2grep -qf pat input; echo $?
1
% pcre2grep -q "" input; echo $?
0

This allows for the more consistent:

% pcre2grep --posix-pattern-file -qf pat input; echo $?
0
% pcre2grep --posix-pattern-file -q -e "" input; echo $?
0

@carenas carenas force-pushed the patfile branch 2 times, most recently from 2458ee4 to 95c9e33 Compare June 17, 2024 05:17
@carenas carenas marked this pull request as draft June 17, 2024 05:36
@carenas carenas marked this pull request as ready for review June 17, 2024 07:05
Historically, pcre2grep has done minor processing of the patterns that
were read through the `-f` option.

The end result is that for some patterns there are different results
depending if they were provided through `-e`, `-f` or as a parameter
in the command line.

Add a flag that could be provided to skip that processing so that the
same pattern file used with other grep implementations could be used
directly for the same result.
@PhilipHazel PhilipHazel merged commit c63d7c9 into PCRE2Project:master Jun 18, 2024
11 checks passed
@carenas carenas deleted the patfile branch June 18, 2024 14:47
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