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

[correctness][confirmed-defect][builtins/cut] cut silently accepts repeated selection lists

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

Línea de trabajo

El defecto está en builtins/cut/cut.go: la bandera de lista se registra con StringP cerca de la línea 101, por lo que un segundo -b sobrescribe el primero, y modeCount cerca de la línea 143 cuenta nombres de banderas distintos en lugar de apariciones. Empieza leyendo la configuración de las banderas y la lógica de conteo de modos, y luego ejecuta el reproductor printf canalizado a cut -b 1 -b 2. Está terminado cuando una bandera de lista repetida sale con código 1 y el mensaje 'cut: only one list may be specified', y una prueba de escenario en tests/scenarios/cmd/cut/errors/ 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-005
  • Classification: confirmed-defect
  • Impact: low
  • Target: builtins/cut
  • Scanned commit: 514d1cb8188fda6b1accca5955dfab3b0e8aa34a

Repeating -b selects only the final list instead of rejecting the second list. GNU rejects repeated list specifications, even when the selection mode is unchanged.

Contract sources
  • [SHELL_FEATURES.md:15](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/SHELL_FEATURES.md#L15): Supported surface; Bash/GNU behavior applies where no intentional divergence is documented.
Implementation references
  • [builtins/cut/cut.go:101](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/builtins/cut/cut.go#L101): StringP overwrites the previous list value.
  • [builtins/cut/cut.go:143](https://github.com/datadog/rshell/blob/514d1cb8188fda6b1accca5955dfab3b0e8aa34a/builtins/cut/cut.go#L143): modeCount counts distinct changed flag names, not occurrences.

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 'abc\n' | cut -b 1 -b 2

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 '"'"'abc\n'"'"' | cut -b 1 -b 2 '
  • LC_ALL=C.UTF-8 /usr/bin/bash --noprofile --norc -c 'printf '"'"'abc\n'"'"' | cut -b 1 -b 2 '
  • GOENV_VERSION=1.26.3 timeout 300s go test ./tests -run '^TestShellScenarios$/^.$/zz_correctness_scan_' -count=2 -v -timeout 300s
Expected

Exit code: 1

stdout:


stderr:

cut: only one list may be specified
Try 'cut --help' for more information.
Actual

Exit code: 0

stdout:

b

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

Fingerprint: 35184ca1c99d958e0fb6e93d5680324e326cc94e1fd52bcd8e712e814d7dd3b8

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.