- 
                Notifications
    You must be signed in to change notification settings 
- Fork 32
grep: add -o option #353
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
base: main
Are you sure you want to change the base?
grep: add -o option #353
Conversation
c50ee1e    to
    05bfe82      
    Compare
  
    0c6ae8b    to
    86ffd89      
    Compare
  
    86ffd89    to
    e4aaa73      
    Compare
  
    | Added an additional change to prevent  | 
| Questions, 
 | 
e4aaa73    to
    2fa5853      
    Compare
  
    | I ran into a build script that was trying to use  Most of the changes are related to switching from UTF-8 types to raw bytes types. It's not too uncommon to want to use text processing tools on "mostly UTF-8 files" (in my case I was trying to search my shell history file, which somehow got some non-UTF-8 bytes in it). Performance is mostly unchanged: "./webster" is "The 1913 Webster Unabridged Dictionary" from https://sun.aei.polsl.pl/~sdeor/index.php?page=silesia (just under 40 mebibytes). | 
| I couldn't find the program I had been trying to compile, but here's an interesting statistic: I have a directory containing 42 Git repositories I've cloned. 4 of those repositories contain scripts that use  https://github.com/hinto-janai/festival | 
| 
 # Get all https URLs.
grep -Eo 'https://.*' text.txt
# Get numbers.
grep -Eo '[0-9]+' text.txt | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces support for the -o option in grep along with several test updates and improved error messages. Key changes include renaming the test file constant from BAD_INPUT_FILE to NONEXISTENT_FILE, updating error message formats to include the "grep:" prefix, and adding tests for the new -o option functionality.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description | 
|---|---|
| text/tests/grep/mod.rs | Renamed file constants, updated error messages, and added tests for the -o option | 
| text/Cargo.toml | Added the memchr dependency | 
Comments suppressed due to low confidence (2)
text/tests/grep/mod.rs:35
- The parameter name was updated from 'test_data' to 'pipe_to_stdin' to improve clarity. Ensure that any related documentation or comments are updated to reflect this change.
fn grep_test(
text/tests/grep/mod.rs:1415
- Consider adding tests for scenarios where multiple matches occur within a single line when using the '-o' option to further ensure correct behavior.
fn test_dash_o() {
No description provided.