feat(sort): drop -h short alias from --help#203
Conversation
GNU sort uses -h as --human-numeric-sort, with --help being long-only. Free the -h slot so we can land --human-numeric-sort/-h next, matching GNU semantics. --help (long form) still prints usage as before. 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: 5d0b1d08f7
ℹ️ 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".
Stale after dropping the -h alias for --help. Spotted by codex on #203. 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: 48403dab0a
ℹ️ 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".
## Summary - Implements GNU sort's `-h`/`--human-numeric-sort` ordering: 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. - Multi-letter suffixes (\`Ki\`, \`Mi\`) are NOT recognised — only the single byte directly following the digits is consumed, matching GNU sort. - Rejects \`-hn\` and \`-dh\` (GNU compat). This is part of a stack enabling the host-remediation demo. The canonical pipeline `du -sh /var/* | sort -rh` now matches the standard incantation. Stacks on top of #203 (which freed the `-h` slot from `--help`). ## Test plan - [x] `make fmt` clean (\`gofmt -l .\` shows no output). - [x] \`go test ./builtins/sort/... ./tests/...\` passes — including 9 new scenarios under \`tests/scenarios/cmd/sort/flags/human_numeric_*.yaml\`: - basic mixed suffixes (1.2G, 500M, 20K, plus no-suffix and equal-suffix tie-break) - long-form flag \`--human-numeric-sort\` - reverse \`-rh\` - tie-break by numeric value within same suffix - no-suffix vs suffixed ordering - negatives (sign category — neg < zero < pos; magnitude reversed within negatives) - combined with \`-u\` - \`du -sh\`-style golden path with size + path columns - \`-hn\` rejection - [x] New unit tests in \`builtins/sort/human_numeric_test.go\` covering the parser (\`parseHumanParts\`) and the comparator (\`compareHuman\`) for: SI suffix order, fractions, negatives, no-suffix, leading blanks, leading-zero stripping, unparseable inputs, '+' as non-sign, and lowercase non-\`k\` suffixes (not recognised). - [x] All existing sort tests still pass. - [ ] \`RSHELL_BASH_TEST=1 go test ./tests/ -run TestShellScenariosAgainstBash -timeout 120s\`: blocked locally on a Docker file-sharing issue (\`bash: /work/runner.sh: No such file or directory\`) that is independent of this change. CI should still validate. ## Notes - Updated \`SHELL_FEATURES.md\` to advertise the new flag and SI suffix list. - Removed the now-stale \`tests/scenarios/cmd/sort/help/short_help_flag.yaml\` scenario (it asserted \`-h\` was rejected; that contract is replaced by the human-numeric scenarios above). 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! ℹ️ 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". |
Summary
sortcurrently maps-hto--help. GNUsortuses-hfor--human-numeric-sortand--helpis long-only.-hso the next branch in the stack can add--human-numeric-sortmatching GNU semantics.--help(long form) still prints usage and exits 0;sort -hnow fails with the standard unknown-flag error.Why
First step in a series of changes to support a disk-space remediation demo (
du -sh /var/* | sort -rh). Splitting this trivial rename out so the human-numeric-sort PR is purely additive.Test plan
go test ./builtins/sort/... ./tests/...passesTestSortShortHRejected) assertssort -hexits 1 withsort:error prefixtests/scenarios/cmd/sort/help/short_help_flag.yamlasserts the same (keptskip_assert_against_bash: truesince GNU sort's-his human-numeric-sort, not unknown)🤖 Generated with Claude Code