[correctness][confirmed-defect][builtins/cut] cut silently accepts repeated selection lists
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
The defect is in builtins/cut/cut.go: the list flag is registered with StringP near line 101, so a second -b overwrites the first, and modeCount near line 143 counts distinct flag names rather than occurrences. Start by reading the flag setup and the mode-counting logic, then run the printf reproducer piped into cut -b 1 -b 2. Done when a repeated list flag exits 1 with 'cut: only one list may be specified', and a scenario test under tests/scenarios/cmd/cut/errors/ covers it.
Written by the indexing model from the issue text.
Description
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
- 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
-
[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 74/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
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
AvengeMedia/DankMaterialShell#3761 ·
Maintainers usually reply within 1 day
-
docs: clarify replacement for outdated Terms of Service URL in readme.mdPossibly taken @mohitjoshi-hey claimed this today. Open
Difficulty 1/5 1-3 hours Newbie friendliness 66/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SocialGouv/iterion#2320 ·
Maintainers usually reply within 1 day
-
helm chart: the first upgrade after install restarts the filer and S3 gateway although nothing changedPossibly taken @egezamb claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
[mesheryctl] Potential runtime panic (index out of range) in system status when pod container statuses are partially populatedPossibly taken @Ayush-AM claimed this today. Opencomponent/mesheryctl kind/bug language/go
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
meshery/meshery#22312 · 2 comments ·
Maintainers usually reply within 1 day