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

what: -s flag prints out of order #753

Merged
merged 1 commit into from
Oct 4, 2024
Merged

Conversation

mknos
Copy link
Contributor

@mknos mknos commented Oct 3, 2024

  • -s flag means to stop searching the current file argument, and move to the next file argument, after the first match
  • Input loop reads lines, and a line might contain NUL
  • NUL is expected to terminate patterns in the same way as newline, but NUL was only handled correctly if -s flag was not set
  • I found this when comparing the output with and without -s
%perl strings /usr/bin/cvs | perl grep -Fi miros  # string order = lowercase miros 1st
@(#)rcsid_bron: $miros: src/gnu/usr.bin/cvs/lib/getdate.y,v 1.14 2021/01/30 02:28:27 tg Exp $
@(#)rcsid_code: $MirOS: src/gnu/usr.bin/cvs/lib/getdate.c,v 1.19 2021/01/30 02:30:17 tg Exp $

%perl what /usr/bin/cvs # all matches
/usr/bin/cvs:
        rcsid_bron: $miros: src/gnu/usr.bin/cvs/lib/getdate.y,v 1.14 2021/01/30 02:28:27 tg Exp $
        rcsid_code: $MirOS: src/gnu/usr.bin/cvs/lib/getdate.c,v 1.19 2021/01/30 02:30:17 tg Exp $

%perl what -s /usr/bin/cvs # one match (patch applied)
/usr/bin/cvs:
        rcsid_bron: $miros: src/gnu/usr.bin/cvs/lib/getdate.y,v 1.14 2021/01/30 02:28:27 tg Exp $

* -s flag means to stop searching the current file argument, and move to the next file argument, after the first match
* Input loop reads lines, and a line might contain NUL
* NUL is expected to terminate patterns in the same way as newline, but NUL was only handled correctly if -s flag was not set
* I found this when comparing the output with and without -s

%perl strings /usr/bin/cvs | perl grep -Fi miros  # string order = lowercase miros 1st
@(#)rcsid_bron: $miros: src/gnu/usr.bin/cvs/lib/getdate.y,v 1.14 2021/01/30 02:28:27 tg Exp $
@(#)rcsid_code: $MirOS: src/gnu/usr.bin/cvs/lib/getdate.c,v 1.19 2021/01/30 02:30:17 tg Exp $
%perl what /usr/bin/cvs # all matches
/usr/bin/cvs:
        rcsid_bron: $miros: src/gnu/usr.bin/cvs/lib/getdate.y,v 1.14 2021/01/30 02:28:27 tg Exp $
        rcsid_code: $MirOS: src/gnu/usr.bin/cvs/lib/getdate.c,v 1.19 2021/01/30 02:30:17 tg Exp $
%perl what -s /usr/bin/cvs # one match (patch applied)
/usr/bin/cvs:
        rcsid_bron: $miros: src/gnu/usr.bin/cvs/lib/getdate.y,v 1.14 2021/01/30 02:28:27 tg Exp $
@github-actions github-actions bot added Type: enhancement improve a feature that already exists Priority: low get to this whenever Program: what The what program labels Oct 3, 2024
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:49 — with GitHub Actions Inactive
@mknos mknos temporarily deployed to automated_testing October 3, 2024 08:50 — with GitHub Actions Inactive
@coveralls
Copy link

coveralls commented Oct 3, 2024

Pull Request Test Coverage Report for Build 11158842148

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 11156912092: -0.7%
Covered Lines: 350
Relevant Lines: 479

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 11158842150

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 73.805%

Totals Coverage Status
Change from base Build 11156912092: 0.0%
Covered Lines: 355
Relevant Lines: 481

💛 - Coveralls

@briandfoy briandfoy merged commit 4bda914 into briandfoy:master Oct 4, 2024
22 of 23 checks passed
@briandfoy
Copy link
Owner

changes: handle -s and nulls properly

@briandfoy briandfoy self-assigned this Oct 4, 2024
@briandfoy briandfoy added Status: accepted The fix is accepted Type: bug an existing feature does not work and removed Priority: low get to this whenever Type: enhancement improve a feature that already exists labels Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Program: what The what program Status: accepted The fix is accepted Type: bug an existing feature does not work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants