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

grep: implement -Bn and -Cn #811

Merged
merged 1 commit into from
Nov 14, 2024
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Nov 14, 2024

  • For -B, context lines before a matching line are saved in a buffer and emptied when a match occurs
  • -C can then be added with no extra logic as a shortcut for -A and -B
  • The old meaning of -C goes away, but I'm not aware of any other version of grep that had that special count feature
  • To test, I modified the file "ar" so it has two consecutive lines matching "this"
%perl grep  -n -C 5 this ar
452-on the command line to ``select'' archive files for an operation, only
453-the first file with a matching name will be selected.
454-
455-The normal use of ar is for the creation and maintenance of libraries
456-suitable for use with the loader (see ld(1)) although it is not
457:this is good
458:restricted to this purpose.
459-
460-=head2 OPTIONS
461-
462-I<ar> accepts the following options:
463-
--
571-Extract the specified archive members into the files named by the
572-command line arguments.  If no members are specified, all the
573-owner and group will be unchanged.  The file access and modifica-
574-tion times are the time of the extraction (but see the -B<o> op-
575-tion).  The file permissions will be set to those of the file
576:when it was entered into the archive; this will fail if the user
577-is not the owner of the extracted file or the super-user.
578-
579-=back
580-
581-I<ar> exits 0 on success, and >0 if an error occurs.
--
596-=head1 COPYRIGHT and LICENSE
597-
598-This program is copyright by dkulp 1999.
599-
600-This program is free and open software. You may use, copy, modify, distribute
601:and sell this program (and any modified variants) in any way you wish,
602-provided you do not restrict others to do the same.
603-
604-=cut
605-

%perl grep  -n -C 1 this ar
456-suitable for use with the loader (see ld(1)) although it is not
457:this is good
458:restricted to this purpose.
459-
--
575-tion).  The file permissions will be set to those of the file
576:when it was entered into the archive; this will fail if the user
577-is not the owner of the extracted file or the super-user.
--
600-This program is free and open software. You may use, copy, modify, distribute
601:and sell this program (and any modified variants) in any way you wish,
602-provided you do not restrict others to do the same.
--

* For -B, context lines before a matching line are saved in a buffer and emptied when a match occurs
* -C can then be added with no extra logic as a shortcut for -A and -B
* The old meaning of -C goes away, but I'm not aware of any other version of grep that had that special count feature
* To test, I modified the file "ar" so it has two consecutive lines matching "this"

%perl grep  -n -C 5 this ar
452-on the command line to ``select'' archive files for an operation, only
453-the first file with a matching name will be selected.
454-
455-The normal use of ar is for the creation and maintenance of libraries
456-suitable for use with the loader (see ld(1)) although it is not
457:this is good
458:restricted to this purpose.
459-
460-=head2 OPTIONS
461-
462-I<ar> accepts the following options:
463-
--
571-Extract the specified archive members into the files named by the
572-command line arguments.  If no members are specified, all the
573-owner and group will be unchanged.  The file access and modifica-
574-tion times are the time of the extraction (but see the -B<o> op-
575-tion).  The file permissions will be set to those of the file
576:when it was entered into the archive; this will fail if the user
577-is not the owner of the extracted file or the super-user.
578-
579-=back
580-
581-I<ar> exits 0 on success, and >0 if an error occurs.
--
596-=head1 COPYRIGHT and LICENSE
597-
598-This program is copyright by dkulp 1999.
599-
600-This program is free and open software. You may use, copy, modify, distribute
601:and sell this program (and any modified variants) in any way you wish,
602-provided you do not restrict others to do the same.
603-
604-=cut
605-


%perl grep  -n -C 1 this ar
456-suitable for use with the loader (see ld(1)) although it is not
457:this is good
458:restricted to this purpose.
459-
--
575-tion).  The file permissions will be set to those of the file
576:when it was entered into the archive; this will fail if the user
577-is not the owner of the extracted file or the super-user.
--
600-This program is free and open software. You may use, copy, modify, distribute
601:and sell this program (and any modified variants) in any way you wish,
602-provided you do not restrict others to do the same.
--
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: grep The grep program labels Nov 14, 2024
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:26 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing November 14, 2024 06:27 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Nov 14, 2024

Pull Request Test Coverage Report for Build 11831906132

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 73.069%

Totals Coverage Status
Change from base Build 11830326870: -0.7%
Covered Lines: 350
Relevant Lines: 479

💛 - Coveralls

@briandfoy briandfoy self-assigned this Nov 14, 2024
@briandfoy briandfoy merged commit b24bf24 into briandfoy:master Nov 14, 2024
22 of 23 checks passed
@briandfoy briandfoy added the Type: compatability make it work like GNU or BSD label Nov 14, 2024
@briandfoy briandfoy added Status: accepted The fix is accepted and removed Priority: low get to this whenever labels Nov 14, 2024
@briandfoy briandfoy added Status: released there is a new release with this fix and removed Status: accepted The fix is accepted labels Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: grep The grep program Status: released there is a new release with this fix Type: compatability make it work like GNU or BSD Type: enhancement improve a feature that already exists
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants