-
Notifications
You must be signed in to change notification settings - Fork 113
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
support -z from GNU grep #457
Comments
I notice BSD grep also supports |
While Note that this flag is often not needed with ugrep, because ugrep matches newline characters explicitly and also other anchors such as end-of-file I probably should add |
A --null-data option would be much appreciated, thanks!
ugrep is in a bit of a sticky spot then. One of its stated goals is "a true drop-in replacement for GNU grep", but if -z is to continue to mean something different between ggrep/ugrep, then that's not an entirely valid claim. I can certainly change my own scripts to use --null-data, but if I've symlinked ugrep as grep somewhere early in my path, and I run someone else's script that relies on grep -z, then I run the risk of a (possibly silent) failure. Maybe a deprecation/reassignment of -z is preferable? |
Yep, but I do remember that some time ago (maybe long ago, like 80s-90s?) GNU grep option |
I've implemented a proto There is also a nice new trick with this, where only the input is treated as a sequence of lines terminated by zero bytes, but the output is not ( Like GNU grep we have the same results with ugrep $ find ~/tmp -name 'testfile*' -print0 | ugrep --null-data '\.txt$' | more -R
/Users/engelen/tmp/testfile
with
newline.txt^@/Users/engelen/tmp/testfile.txt^@ The trick to only convert the input as null data without converting back in the output: $ find ~/tmp -name 'testfile*' -print0 | ugrep --encoding=null-data '\.txt$' | more -R
/Users/engelen/tmp/testfile^@with^@newline.txt
/Users/engelen/tmp/testfile.txt The This might perhaps be useful to someone. Let me add that a second trick is possible to output as The man page summary of
About option |
One way to get around the This is something that is left open to discuss. |
I see the logic of having Either way I think the difference should be mentioned in the ReadMe in the section on "Equivalence to GNU/BSD grep". |
@stephentalley @AndrewDDavis I've committed an update to the source code master branch. It would be of great help if you could try this version's support for |
It could be done with a new flag
See my comment above. Symlinking or copying EDIT: #269 is related to this discussion, where |
Not rly. Most awesome / Sanest practice EVER to consider On tangents:
I'd hope that "I cannot use aliases", since the default bashrc file already has "colorful" grep aliases (You cannot define multiple aliases) |
@stdedos thanks. Having an "enhanced grep compatibility mode" makes sense if we want What does this mean? Well, when ugrep is installed as GNU/BSD grep replacements The
In addition, the Any concerns, comments or suggestions? |
I've tagged the dev updates, the first with |
I think you have this well-thought. Going "so far" as to even "amend" the If I may - I would avoid "hiding" things. This is a different program that "plain grep". No need to hide it. Similarly, e.g. for
I'm struggling for the "correct" balance of DWIM, and being "too magical" even going so far as "hiding" things. I like DWIM, because, it's nice when things "just happen". But I also like to know that DWIM is at play, so, "if I feel it doesn't work for me", I can be aware that it happens.
"Eventually" I'll "stalk" your tags and build Debian packages for each one of them. ... But that project is left aside for a couple of years by now 😓 |
It would be nice to update Debian packages when 7.2.0 is released. It looks like Debian is stuck with an old 3.11 release of ugrep. Much has improved since then. Fewer users will update ugrep from Debian and many will use this GitHub repo or the ugrep static builds instead. This is not desirable for Debian either, since the ugrep installation statistics will not be lagging. At least Ubuntu has a much more recent version of ugrep v6.4. |
Eeeh ... True. But I like "the order" from installing from the official package manager. ... and since I've done the work for it. I just need to setup CI/CD for it (i.e. build tags, track your repo), and "rationalize" how can I update from you, and keep my changes on top too. |
I appreciate all your efforts to keep software packages up to date. I understand it is time consuming. I try to be as transparent as possible by indicating what changed in a release update. I am also committing intermediate feature request changes and fixes, so the source code can be diff'ed to see what the actual source code updates are. I've now also started to tag these commits when addressing a feature request or fix. When I'm happy with the update after more reviews and testing then I will release an official update (v7.2 will be released soon). I don't know if that helps to follow the changes e.g. by package maintainers who are concerned about what they are packaging. |
Don't worry about all these 😅 It was my decision to do this. ... and I am doing a "bare minimum" - I don't think those changes "stand up" to serious Debian/Ubuntu maintainers. ... tbh, it's hard for me to see "what changed and why" (I'm reviewing your changes out of curiosity 😛) - but it could very well be my limitation - I don't have C++ experience, and definitely very old C experience 😓 And since I'm forking your repo - regardless of the things I add above it - there is a transparent (and minimal) chain of changes (if those are to someone's interest) |
I've released ugrep v7.2. Thank you for your feedback! |
Thank you for offering us a very nice product, being available and open to listen 🙃 |
I recently tried to use ugrep as a drop-in replacement for GNU grep in a shell script, but was thwarted by ugrep's lack of support for GNU grep's -z option. That option interprets an input "line" as a NUL-delineated chunk rather than a newline-delineated chunk.
Example:
I see that ugrep supports -0, which affects only output. -z affects both input and output in GNU grep.
It would be nice to be able to have this feature parity with GNU grep. Thanks!
The text was updated successfully, but these errors were encountered: