feat(sort): add -h/--human-numeric-sort#204
Conversation
Implements GNU sort's human-numeric ordering: sorts first by sign
(negative, zero, positive), then by SI suffix magnitude (none < K/k <
M < G < T < P < E < Z < Y), then by numeric value within the same
suffix. Multi-letter suffixes ("Ki", "Mi") are not recognised — only
the single byte directly following the digits is consumed, matching
GNU sort.
This unlocks the canonical disk-space pipeline `du -sh ... | sort -rh`
for the host-remediation demo. Combines normally with -r, -u, -k, -t,
-b, and -f. Rejects the GNU-incompatible combinations -hn and -dh.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
f5a0087 to
8ff4ff7
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ff4ff7d8b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Two GNU-compat fixes from codex review on #204: 1. sort -fh now folds case before the human-numeric parser runs, so lowercase SI suffixes (1m, 1g, ...) are recognised as their uppercase counterparts. Previously they fell through as no-suffix values and sorted incorrectly. 2. sort -h -n is accepted when every -k spec carries its own ordering option (matching GNU's deferred -dn-style validation). The unconditional -hn check ran before key parsing and rejected otherwise valid command lines like `sort -h -n -k1,1h`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b3027e6656
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
AGENTS.md requires |+ block scalars for input.script, expect.stdout, and expect.stderr — even when the value is single-line or empty. Convert the empty stdout/stderr expectations in the new human_numeric scenarios to |+. Caught by codex on #204. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98b4365cb5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
GNU sort's full SI suffix table is "kKMGTPEZYRQ". My initial implementation stopped at Y, leaving R and Q at order 0 — so values like 1R/1Q would sort BEFORE 1K instead of above 1Y. Add the missing two suffixes, update the docs, and add unit + scenario coverage. The new ronna_quetta scenario is marked skip_assert_against_bash because debian:bookworm-slim ships coreutils 9.1 (predating R/Q, which landed in 9.4). Caught by codex on #204. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
83db863
into
jules.macret/host-remediation/sort-h
Summary
-h/--human-numeric-sortordering: by sign (negative, zero, positive), then SI suffix magnitude (none < K/k < M < G < T < P < E < Z < Y), then by numeric value within the same suffix.This is part of a stack enabling the host-remediation demo. The canonical pipeline
du -sh /var/* | sort -rhnow matches the standard incantation. Stacks on top of #203 (which freed the-hslot from--help).Test plan
make fmtclean (`gofmt -l .` shows no output).Notes
🤖 Generated with Claude Code