[correctness][confirmed-defect][builtins/printf] printf hexadecimal zero padding exceeds the requested width
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
该问题位于 builtins/printf/printf.go:591 的 %#0...x 分支,该分支将格式字符串直接传给 fmt.Sprintf,因此 0x 前缀被计入零填充宽度之外。请从这里开始,运行 printf '%#08x\n' 31 进行复现;Bash 的输出为 0x00001f。当输出为 0x00001f,且在 tests/scenarios/cmd/printf/width_precision/ 下新增的场景测试通过时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
Generated by the rshell behavior correctness scanner.
- Contract:
BEH-007 - Classification:
confirmed-defect - Impact:
low - Target:
builtins/printf - Scanned commit:
514d1cb8188fda6b1accca5955dfab3b0e8aa34a
For %#08x, the 0x prefix should be included in the eight-character width. Go formatting adds it outside the zero-padding width, producing ten characters.
Contract sources
[SHELL_FEATURES.md:42](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/SHELL_FEATURES.md#L42): Supported surface; Bash/GNU behavior applies where no intentional divergence is documented.
Implementation references
[builtins/printf/printf.go:591](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/builtins/printf/printf.go#L591): The %#0...x format is delegated directly to fmt.Sprintf, whose prefix-width behavior differs.
Fixture setup
Use a fresh empty working directory for each run. Build from /workspace/repo first. No fixture files are needed. Run the CLI and reference commands with that directory as cwd.
Reproducer
printf '%#08x\n' 31
Commands used:
GOENV_VERSION=1.26.3 timeout 300s go build -o /tmp/zz_correctness_scan_rshell ./cmd/rshell/tmp/zz_correctness_scan_rshell --allow-all-commands --allowed-paths "$PWD" -c 'printf '"'"'%#08x\n'"'"' 31 'LC_ALL=C.UTF-8 /usr/bin/bash --noprofile --norc -c 'printf '"'"'%#08x\n'"'"' 31 'GOENV_VERSION=1.26.3 timeout 300s go test ./tests -run '^TestShellScenarios$/^.$/zz_correctness_scan_report_' -count=2 -v -timeout 300s
Expected
Exit code: 0
stdout:
0x00001f
stderr:
Actual
Exit code: 0
stdout:
0x0000001f
stderr:
Verification
- Reproduction runs: 4
- Reference: Two fresh CLI fixtures and two fresh scenario fixtures; exploratory runs excluded. Native Bash 5.2.21, GNU coreutils 9.4, grep 3.11, sed 4.9, LC_ALL=C.UTF-8. Docker comparison attempted but image pull returned HTTP 502.
- Temporary test: tests/scenarios/zz_correctness_scan_report_printf_hex.yaml (removed after evidence capture)
- Suggested regression-test location:
tests/scenarios/cmd/printf/width_precision/
Fingerprint: 5d9d4ff2741d619577d03418cae78fd4c74a2f671c5efa61c3342282bfb1e617
- 主要语言
- Go
- 星标
- 31
- 派生
- 3
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 14
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DataDog/rshell 的其他 Issue
-
难度 1/5 1 小时以内 新手友好度 75/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
[correctness][confirmed-defect][builtins/wc] wc pads regular-file stdin as though it were a pipe未关闭
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
相似的 Issue
-
copilot-api domain:platform go
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
docs: clarify gh api -f vs -F and @-file expansion in the gh skill可能已有人在做 @MatiasOlivera 今天认领。 未关闭enhancement
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
aws/aws-advanced-go-wrapper#612 ·
-
Say in the changelog that the text-index update cannot be rolled back可能已有人在做 @praetorianer777 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 88/100
praetorianer777/GoTome#275 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
SAP/crossplane-provider-btp#1118 ·
维护者通常 1 天内回复