Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Open Beginner friendly
#660 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go
Domain
cli

Research direction

The stdin formatting decision is in builtins/wc/wc.go: hasNonRegular is set whenever stdin is used (around line 176), and that flag forces a minimum width of seven (around line 216). Run the reproducer wc -lc < zz_correctness_scan_input in a temp directory and compare it with bash -c output, then check that hasNonRegular only applies to pipes. Done means 2 8 for a regular-file redirect with pipe behavior unchanged, and a scenario under tests/scenarios/cmd/wc/formatting/ covers it.

Written by the indexing model from the issue text.

Description

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

Dominant language
Go
Stars
31
Forks
3
Avg merge
2d 9h
Merged PRs (30d)
14

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from DataDog/rshell

All issues in DataDog/rshell

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.