grep: cover zero-width EOF only-matching behavior (#44)

This commit is contained in:
Wondr
2026-06-05 15:52:30 +01:00
committed by GitHub
parent 55a7b0180b
commit bc61aece73
+17
View File
@@ -587,6 +587,23 @@ fn only_matching() {
.succeeds()
.stdout_only("Hello\nhELLO\nHELLO\n");
// Zero-width matches do not print in -o mode, but still mark the line as
// matched. This matters for -v because matched lines must not be selected.
let (_s, mut c) = ucmd();
c.args(&["-o", "$"]).pipe_in("\n").succeeds().no_output();
let (_s, mut c) = ucmd();
c.args(&["-o", "-v", "$"])
.pipe_in("a\n\nb\n")
.fails_with_code(1)
.no_output();
let (_s, mut c) = ucmd();
c.args(&["-o", "-v", "x*"])
.pipe_in("a\n\nb\n")
.fails_with_code(1)
.no_output();
// After a match ends, ^ must not re-match at that position.
let (_s, mut c) = ucmd();
c.args(&["-o", "^hello*"])