sed - with `--posix`, `-e 'i\'` takes the next `-e` as its text
维护者通常 1 天内回复
评估
调研方向
首先阅读 GNU sed 测试 compile-errors 和 issue 中提到的代码 compile_text_command_posix,然后使用 --posix 运行提供的复现步骤。在表达式边界处,为 a\、i\ 和 c\ 添加所示的回归测试用例。完成标准是:POSIX 用例以退出码 1 和“incomplete command”失败,而 GNU 扩展用例仍然成功。
由索引模型根据 Issue 内容生成。
描述
As a GNU extension, sed -e 'i\' -e hello uses the next -e fragment as the
text of a, i or c. With --posix, GNU sed does not join the fragments,
and an a\, i\ or c\ at the end of an -e is an incomplete command.
uutils sed joins them in both modes. The same text in one -f file (i\
followed by hello on the next line) is valid POSIX and works in both
implementations.
The GNU test compile-errors exposes this. Open PR #625 rewrites
compile_text_command_posix, but a build of it still accepts this case.
Reproduction
Rust (incorrect)
$ echo w | ./target/release/sed --posix -e 'i\' -e hello
hello
w
# Exit code: 0
GNU (correct)
$ echo w | sed --posix -e 'i\' -e hello
sed: -e expression #1, char 2: incomplete command
# Exit code: 1
$ echo w | sed -e 'i\' -e hello
hello
w
# Exit code: 0
Test
#[rstest]
#[case::append("a\\")]
#[case::insert("i\\")]
#[case::change("c\\")]
fn test_posix_text_command_stops_at_expression_end(#[case] cmd: &str) {
new_ucmd!()
.args(&["--posix", "-e", cmd, "-e", "second fragment"])
.pipe_in("line\n")
.fails()
.code_is(1)
.no_stdout()
.stderr_contains("incomplete command");
// GNU extension: without --posix the next fragment is the text.
new_ucmd!()
.args(&["-e", cmd, "-e", "second fragment"])
.pipe_in("")
.succeeds()
.no_output();
}
Exposed by the GNU sed test suite: compile-errors.
- 主要语言
- Rust
- 星标
- 123
- 派生
- 53
- 平均合并
- 2 天 8 小时
- 30 天内合并 PR
- 40
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/sed 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
sed - script parser skips CR, VT, FF (and 0x85, 0xA0) as blanks; GNU skips only space and tab可能已有人在做 @Himanshu-singh04 于 22 天前认领。 未关闭bug gnu-compat good first issue oss-scanner
难度 2/5 1-3 小时 新手友好度 89/100
维护者通常 1 天内回复
-
sed - with `-s` or `-i`, the file read by `R` is not restarted for each input file可能已有人在做 @Himanshu-singh04 于 22 天前认领。 未关闭bug gnu-compat good first issue oss-scanner
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
sed - output already produced is lost when a runtime error stops processing可能已有人在做 @Himanshu-singh04 于 21 天前认领。 未关闭bug gnu-compat good first issue oss-scanner
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 1 天内回复
-
sed - unknown POSIX class names like `[[:foo:]]` or `[[:word:]]` are accepted instead of rejected可能已有人在做 @draarivpatel-ui 于 7 天前认领。 未关闭bug gnu-compat good first issue oss-scanner
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
autofix:working
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 75/100
libracoder/kiri#1138 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 83/100
roc-lang/basic-webserver#277 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 82/100
samkerrcode/opengent#113 ·
维护者通常 1 天内回复
-
app bug session
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复