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

[correctness][confirmed-defect][builtins/wc] wc pads regular-file stdin as though it were a pipe

Abierto Apto para principiantes
#660 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
78/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
go
Área
cli

Línea de trabajo

La decisión del formato de stdin está en builtins/wc/wc.go: hasNonRegular se activa siempre que se usa stdin (alrededor de la línea 176), y esa marca fuerza un ancho mínimo de siete (alrededor de la línea 216). Ejecuta el reproductor wc -lc < zz_correctness_scan_input en un directorio temporal y compara su salida con la de bash -c. Después comprueba que hasNonRegular solo se aplica a las pipes. Está terminado cuando 2 8 aparece en una redirección a un archivo regular, el comportamiento de las pipes no cambia y un escenario en tests/scenarios/cmd/wc/formatting/ lo cubre.

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/wc
  • Scanned commit: 514d1cb8188fda6b1accca5955dfab3b0e8aa34a

wc -lc < file adds seven-column padding instead of the GNU regular-file formatting. Counts are correct; deterministic stdout bytes are not.

Contract sources
  • [SHELL_FEATURES.md:58](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/SHELL_FEATURES.md#L58): Supported surface; Bash/GNU behavior applies where no intentional divergence is documented.
Implementation references
  • [builtins/wc/wc.go:176](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/builtins/wc/wc.go#L176): hasNonRegular is set merely because stdin is used.
  • [builtins/wc/wc.go:216](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/builtins/wc/wc.go#L216): That flag forces minimum width seven even for a regular-file redirect.

Fixture setup

Use a fresh empty working directory for each run. Build from /workspace/repo first. Create these UTF-8 files with exactly the following contents (JSON string notation): {"zz_correctness_scan_input": "one\ntwo\n"}. Run the CLI and reference commands with that directory as cwd.

Reproducer

wc -lc < zz_correctness_scan_input

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 'wc -lc < zz_correctness_scan_input '
  • LC_ALL=C.UTF-8 /usr/bin/bash --noprofile --norc -c 'wc -lc < zz_correctness_scan_input '
  • GOENV_VERSION=1.26.3 timeout 300s go test ./tests -run '^TestShellScenarios$/^.$/zz_correctness_scan_' -count=2 -v -timeout 300s
Expected

Exit code: 0

stdout:

2 8

stderr:


Actual

Exit code: 0

stdout:

      2       8

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_wc_seekable_format.yaml (removed after evidence capture)
  • Suggested regression-test location: tests/scenarios/cmd/wc/formatting/

Fingerprint: fcf7755d6ac7070d8f8b00c3ee045a2e875d56641b19c176402e3797e485b1f1

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.