Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[correctness][confirmed-defect][builtins/printf] printf hexadecimal zero padding exceeds the requested width

Abierto Apto para principiantes
#659 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
74/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
cli

Línea de trabajo

El error está en la rama %#0...x de builtins/printf/printf.go:591, que pasa el formato directamente a fmt.Sprintf, por lo que el prefijo 0x se cuenta fuera del ancho de relleno con ceros. Empieza ahí y ejecuta printf '%#08x\n' 31 para reproducirlo; Bash imprime 0x00001f. Está terminado cuando la salida es 0x00001f y un escenario añadido en tests/scenarios/cmd/printf/width_precision/ pasa.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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

Lenguaje dominante
Go
Estrellas
31
Forks
3
Merge medio
2 d 9 h
PR fusionados (30 d)
14

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de DataDog/rshell

Todos los issues de DataDog/rshell

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.