You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(uniq): pad -c count to 7 characters like GNU uniq (fixes #777) - #792
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
uniq.ts: widen the count field from padStart(4) to padStart(7).
debugging-workflow.test.ts: update the pinned uniq -c expectation to
the new width.
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).
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GNU coreutils
uniqright-justifies the-ccount 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.
Changes
uniq.ts: widen the count field frompadStart(4)topadStart(7).uniq.test.ts: update the-cexpectation to the 7-character field and adda regression test with the exact repro from uniq -c pads the count to 4 characters; GNU uniq uses 7 #777.
uniq.comparison.test.ts+ fixture: add a comparison test for the uniq -c pads the count to 4 characters; GNU uniq uses 7 #777repro input, with the fixture recorded from GNU uniq.
debugging-workflow.test.ts: update the pinneduniq -cexpectation tothe new width.
Verification
uniq -crepro now outputs" 2 a\n 1 b\n", matching GNU uniq 9.4.uniq -c(agent examples, overlay-fs e2e, teeplugin): 238/238 passed.
typecheckandlint(incl. biome on the changed files) clean.just-bashsuite: no uniq failures; the only failures arepre-existing ones also present on the clean tree (bundle tests needing a
build, network/security sandbox tests, spec-test known failures).