Skip to content

fix(uniq): pad -c count to 7 characters like GNU uniq (fixes #777) - #792

Open
anhnt256 wants to merge 9 commits into
vercel-labs:mainfrom
anhnt256:fix/uniq-count-width-7
Open

anhnt256 wants to merge 9 commits into
vercel-labs:mainfrom
anhnt256:fix/uniq-count-width-7

Conversation

@anhnt256

@anhnt256 anhnt256 commented Dec 4, 2026

Copy link
Copy Markdown

GNU coreutils uniq right-justifies the -c count in a 7-character field,
but just-bash used a 4-character field (the BSD/macOS width). That makes
output cut by column position differ from Linux, e.g. uniq -c | cut -c9-
returns blank lines instead of the lines.

$ printf 'a\na\nb\n' | uniq -c
      2 a
      1 b

Changes

Verification

  • uniq -c repro now outputs " 2 a\n 1 b\n", matching GNU uniq 9.4.
  • uniq unit tests: 16/16 passed; uniq comparison tests: 17/17 passed.
  • Downstream tests using uniq -c (agent examples, overlay-fs e2e, tee
    plugin): 238/238 passed.
  • typecheck and lint (incl. biome on the changed files) clean.
  • Full just-bash suite: no uniq failures; the only failures are
    pre-existing ones also present on the clean tree (bundle tests needing a
    build, network/security sandbox tests, spec-test known failures).

@vercel

vercel Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

@anhnt256 is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@auto-maintain

auto-maintain Bot commented Dec 4, 2026

Copy link
Copy Markdown

🤖 auto-maintain review

Automated, advisory triage for @anhnt256's PR. Facts below are read from the GitHub API.

Check Result
Author's merged PRs (this repo) 0 — ⚠️ first-time contributor
Account established ✅ (age 3865d · 3 followers · 74 public repos)
Commits signed/verified ✅ 5/5
Changeset included ⚠️

Review panel: 🟡 medium highest severity

just-bash maintainer code review: 🟡 medium

The implementation is correct, but the new GNU regression fixture is not protected from platform-specific re-recording.

  • packages/just-bash/src/comparison-tests/fixtures/uniq.comparison.fixtures.json:97 — Mark this GNU-specific fixture as `locked`. Unlike every other `uniq -c` fixture, it is currently overwritten by `RECORD_FIXTURES=1`; on BSD/macOS that silently replaces the seven-column GNU output with four-column output.

General code review: 🟡 medium

Implementation is correct, but the added comparison regression test does not actually verify the spacing it claims to cover.

  • packages/just-bash/src/comparison-tests/uniq.comparison.test.ts:75 — The GNU-spacing regression test passes `normalizeWhitespace`, which strips the leading padding and would also pass the old 4-character output. Compare this GNU fixture exactly instead; its fixture should also remain locked against BSD re-recording.

Adversarial security: 🟢 low

No actionable security issues found in the complete base-to-head diff.

Adversarial security (second opinion): 🟡 medium

No security concerns: the diff is a one-line output-width change plus test/fixture updates, with no networking, process execution, dependency, CI, or trust-boundary impact, and the 7-column width matches GNU uniq and the repo's existing locked fixtures; however two files are left in a non-Biome-formatted state that will fail the Lint job, and the added comparison test is normalized such that it cannot detect the bug it claims to cover.

  • packages/just-bash/src/commands/uniq/uniq.test.ts:29 — Misindented closing paren (` );` at 6 spaces instead of 4) is not Biome-formatted output; `pnpm lint` runs `biome check .` which includes format diagnostics, so the Lint CI job will fail despite the PR claiming "lint clean".
  • packages/just-bash/src/comparison-tests/uniq.comparison.test.ts:76 — Same formatting problem here: the `await compareOutputs(` call closes with ` );` at 4 spaces inside a 6-space block, which `biome check .` will reject.
  • packages/just-bash/src/comparison-tests/uniq.comparison.test.ts:69 — The new comparison test passes `uniqCountOptions` (`normalizeWhitespace: true`), which trims and collapses leading whitespace before comparing — so it cannot detect the padding width at all and would pass equally with padStart(4) or padStart(7). As a regression guard for uniq -c pads the count to 4 characters; GNU uniq uses 7 #777 it is vacuous; only the unit test actually pins the width.
  • packages/just-bash/src/comparison-tests/fixtures/uniq.comparison.fixtures.json:92 — The new fixture omits `"locked": true`, unlike every other `uniq -c` fixture in this file. Locking is the repo's mechanism for pinning GNU-recorded output; without it a local `RECORD_FIXTURES=1` run on macOS/BSD will silently overwrite this entry with BSD 4-column output while the locked siblings keep GNU output, committing a host-dependent fixture (CI records on ubuntu so it won't catch the divergence).

Standard Bash and host portability: 🟡 medium

The implementation is portable, but the new GNU-specific fixture must be locked against host-dependent re-recording.

  • packages/just-bash/src/comparison-tests/fixtures/uniq.comparison.fixtures.json:97 — This GNU-specific count fixture is not marked `locked`, unlike every other `uniq -c` fixture. Running fixture recording on BSD/macOS will overwrite it with BSD's 4-character field, creating platform-dependent fixture churn and losing the intended GNU reference output.

Posted by auto-maintain. This automated code review is advisory; a human maintainer makes the call.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant