grep - `-L` with `-m 0` or `-v ''` prints nothing; GNU still lists every file
维护者通常 2 天内回复
评估
调研方向
issue指出了 uu_grep 的提前退出,并包含一个 Rust 回归测试,但没有提供源文件或测试文件路径。首先找到该提前退出的位置以及现有针对 -L 的 grep 测试;添加给出的 -m 0 和 -v -e '' 用例,检查可读文件会被列出,同时退出代码仍为 1。GNU 的 skip-read 用例也需要覆盖 -G、-E 和 -F。
由索引模型根据 Issue 内容生成。
描述
When no line can be selected (-m 0, or -v with an empty pattern) uu_grep exits 1 before
opening any file. That is right for plain output, -c, -l and -q, but not for
-L/--files-without-match: every file then has no selected line, and GNU grep lists each
readable file (and still reports files it cannot open). uu_grep prints nothing.
Exposed by the GNU test skip-read (grep -L -m0 y /dev/null and grep -L -v "" /dev/null must print /dev/null, with -G, -E and -F).
Reproduction
$ printf 'red\n' > colors
Rust (incorrect)
$ ./target/release/grep -L -m 0 red colors
# Output: (none)
# Exit code: 1
$ ./target/release/grep -L -v -e '' colors
# Output: (none)
# Exit code: 1
GNU (correct)
$ LC_ALL=C /usr/bin/grep -L -m 0 red colors
colors
# Exit code: 1
$ LC_ALL=C /usr/bin/grep -L -v -e '' colors
colors
# Exit code: 1
$ LC_ALL=C /usr/bin/grep -L -m 0 red colors nosuch
colors
/usr/bin/grep: nosuch: No such file or directory
# Exit code: 2
Test
#[test]
fn files_without_match_with_nothing_selectable() {
for args in [&["-L", "-m", "0", "pine"][..], &["-L", "-v", "-e", ""][..]] {
let (scene, mut c) = ucmd();
scene.fixtures.write("trees.txt", "pine\noak\n");
c.args(args)
.arg("trees.txt")
.fails_with_code(1)
.stdout_only("trees.txt\n");
}
}
Exposed by the GNU grep test suite: skip-read.
- 主要语言
- Rust
- 星标
- 147
- 派生
- 34
- 平均合并
- 3 天 18 小时
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/grep 的其他 Issue
-
grep - `-v -o` with `-A`/`-B`/`-C` prints nothing; GNU prints the matches found in the context lines未关闭bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 2 天内回复
-
grep - interval counts above 32767 are accepted; GNU rejects them with `Regular expression too big`可能已有人在做 @yunusarda-sudo 于 5 天前认领。 未关闭bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 79/100
维护者通常 2 天内回复
-
grep - `--exclude-dir=./dir` does not exclude the operand `./dir`可能已有人在做 @yunusarda-sudo 于 5 天前认领。 未关闭bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 2 天内回复
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
gnu-compat good first issue oss-scanner
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 2 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
code-quality parser
难度 2/5 1-3 小时 新手友好度 88/100
eventflux-io/eventflux#218 ·
维护者通常 1 天内回复
-
StartSso docs say an option requires the built-in AuthnRequest renderer, which is now the only one未关闭documentation needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
marketing
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复