[correctness][confirmed-defect][builtins/printf] printf hexadecimal zero padding exceeds the requested width
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
Research direction
The bug is in the %#0...x branch at builtins/printf/printf.go:591, which passes the format straight to fmt.Sprintf, so the 0x prefix is counted outside the zero-padding width. Start there and run printf '%#08x\n' 31 to reproduce; Bash prints 0x00001f. Done when the output is 0x00001f and a scenario added under tests/scenarios/cmd/printf/width_precision/ passes.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Go
- Stars
- 31
- Forks
- 3
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 14
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from DataDog/rshell
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
[correctness][confirmed-defect][builtins/wc] wc pads regular-file stdin as though it were a pipeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
docs(prompt): filer socket fragment hardcodes an issue-intent cap of 8 that Chore runs overrideOpenagent-butler-finding chore
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jordansmall/spindrift#5128 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 2 days
-
License GOtome under Apache 2.0 instead of AGPL-3.0Possibly taken @praetorianer777 claimed this today. Openarea:workflow documentation
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
praetorianer777/GoTome#212 ·
Maintainers usually reply within 1 day
-
ci: pin Go version in Build and Unit Test workflows (>=1.26.6 floats to 1.27.2 and breaks golangci-lint)Possibly taken @leninmehedy claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
hashgraph/solo-weaver#1255 ·
Maintainers usually reply within 1 day
-
area/infra backlog type/chore
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
praetorianer777/Stator#374 ·
Maintainers usually reply within 1 day