awk: `-f missing-file` and `--source` panic
维护者通常 1 天内回复
评估
调研方向
从 parser/src/lib.rs:1037 中对 -f 的处理,以及 src/main.rs:51 中对 --source 的处理开始,issue 在这两处报告了 panic。为缺少程序文件和单独使用 --source 添加或使用列出的回归测试,然后确认前者报告错误且不包含“panicked”,后者输出 from source 并成功退出。
由索引模型根据 Issue 内容生成。
描述
Two ways of giving the program text crash instead of running or reporting an
error:
-fwith a file that cannot be opened panics onunwrap();--source TEXT(-e) without-fpanics because the code looks for the
positional program argument.
Reproduction
Rust (incorrect)
$ ./target/release/awk -f missing.awk
thread 'main' panicked at parser/src/lib.rs:1037:38:
called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
# Exit code: 2
$ ./target/release/awk --source 'BEGIN { print 1 }'
thread 'main' panicked at src/main.rs:51:43:
called `Option::unwrap()` on a `None` value
GNU (correct)
$ gawk -f missing.awk
gawk: fatal: cannot open source file `missing.awk' for reading: No such file or directory
# Exit code: 2
$ gawk --source 'BEGIN { print 1 }'
1
Test
#[test]
fn missing_program_file_is_an_error() {
ucmd()
.args(&["-f", "does-not-exist.awk"])
.fails_with_code(2)
.stderr_contains("does-not-exist.awk")
.stderr_does_not_contain("panicked");
}
#[test]
fn source_option_alone() {
ucmd()
.args(&["--source", "BEGIN { print \"from source\" }"])
.succeeds()
.stdout_only("from source\n");
}
Exposed by the GNU awk test suite: sourcesplit, space, incdupe2, incdupe3,
incdupe4, incdupe7.
- 主要语言
- Rust
- 星标
- 31
- 派生
- 13
- 平均合并
- 23 小时 42 分钟
- 30 天内合并 PR
- 29
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/awk 的其他 Issue
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug crash gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
相似的 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 天内回复