Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#662 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go
Lĩnh vực
cli

Hướng nghiên cứu

Lỗi nằm trong builtins/cut/cut.go: cờ danh sách được đăng ký bằng StringP gần dòng 101, vì vậy -b thứ hai ghi đè -b thứ nhất, còn modeCount gần dòng 143 đếm số tên cờ khác nhau thay vì số lần xuất hiện. Hãy bắt đầu bằng việc đọc phần thiết lập cờ và logic đếm chế độ, sau đó chạy đoạn tái hiện printf được pipe vào cut -b 1 -b 2. Công việc hoàn thành khi một cờ danh sách lặp lại thoát với mã 1 và thông báo 'cut: only one list may be specified', và một kiểm thử kịch bản trong tests/scenarios/cmd/cut/errors/ bao phủ trường hợp này.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Go
Star
31
Fork
3
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của DataDog/rshell

Tất cả issue của DataDog/rshell

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.