grep - the interval `{,}` (`\{,\}` in BRE) is rejected or read literally; GNU reads it as `{0,}`
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start by locating the regex parsing and matching paths for basic and extended modes, then review the existing grep tests and the GNU bre test, especially Spencer BRE test #40. Add coverage for \{,\} and {,} matching zero or more occurrences, using the supplied reproduction and expected output. Done means both modes select the same lines as GNU grep and the regression test passes.
由索引模型根据 Issue 内容生成。
描述
Known: closed PR #152 (closed by its author without merging) — https://github.com/uutils/grep/pull/152
GNU grep reads an interval with neither bound, {,}, as {0,} (the same as *). In basic
mode uu_grep rejects \{,\} with an Oniguruma error and exit 2; in extended mode it reads
{,} as literal text and so selects different lines. PR #152 rewrote the pattern text and
was closed; no issue tracks the behaviour.
Exposed by the GNU test bre (Spencer BRE test #40, a\{,\} must match a\{,\}).
Reproduction
Rust (incorrect)
$ printf 'mo\nmooo\n' | ./target/release/grep 'mo\{,\}'
grep: invalid pattern "mo\{,\}": invalid repeat range {lower,upper}
# Exit code: 2
$ printf 'mo\nmooo\n' | ./target/release/grep -E 'mo{,}'
# Output: (none)
# Exit code: 1
GNU (correct)
$ printf 'mo\nmooo\n' | LC_ALL=C /usr/bin/grep 'mo\{,\}'
mo
mooo
# Exit code: 0
$ printf 'mo\nmooo\n' | LC_ALL=C /usr/bin/grep -E 'mo{,}'
mo
mooo
# Exit code: 0
Test
#[test]
fn empty_interval_means_zero_or_more() {
for args in [&["-c", "bz\\{,\\}"][..], &["-c", "-E", "bz{,}"][..]] {
let (_s, mut c) = ucmd();
c.args(args)
.pipe_in("b\nbzzz\nq\n")
.succeeds()
.stdout_only("2\n");
}
}
Exposed by the GNU grep test suite: bre.
- 主要语言
- Rust
- 星标
- 147
- 派生
- 34
- 平均合并
- 3 天 18 小时
- 30 天内合并 PR
- 21
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/grep 的其他 Issue
-
grep - `-L` with `-m 0` or `-v ''` prints nothing; GNU still lists every file可能已有人在做 @yunusarda-sudo 于 5 天前认领。 未关闭bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 83/100
维护者通常 2 天内回复
-
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 天内回复
相似的 Issue
-
marketing
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
S: Untriaged T: Bug
难度 2/5 1-3 小时 新手友好度 72/100
libnyanpasu/clash-nyanpasu#6537 ·
维护者通常 1 天内回复
-
难度 2/5 1 小时以内 新手友好度 62/100
tauri-apps/tao#1445 ·
维护者通常 1 天内回复
-
bug P3
难度 1/5 1-3 小时 新手友好度 88/100
-
go good first issue test
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 2 天内回复