Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#662 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
cli

Direzione di ricerca

Il difetto si trova in builtins/cut/cut.go: il flag di lista è registrato con StringP vicino alla riga 101, quindi un secondo -b sovrascrive il primo, e modeCount vicino alla riga 143 conta i nomi di flag distinti invece delle occorrenze. Inizia leggendo la configurazione dei flag e la logica di conteggio delle modalità, poi esegui il riproduttore printf inviato a cut -b 1 -b 2. È completato quando un flag di lista ripetuto termina con codice 1 e il messaggio 'cut: only one list may be specified', e un test di scenario in tests/scenarios/cmd/cut/errors/ lo copre.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
Go
Stelle
31
Fork
3
Merge medio
2g 9h
PR unite (30g)
14

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di DataDog/rshell

Tutte le issue di DataDog/rshell

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.