Skip to content

fix(small-batch): hostname -F (#1526 + #1528 wide-path restore), diff clamp (#1527), ls COLUMNS (#1504), grep --color usage (#1516) - #1534

Merged
caomengxuan666 merged 2 commits into
mainfrom
fix/small-batch-1526-1527-1504
Nov 7, 2026
Merged

caomengxuan666 merged 2 commits into
mainfrom
fix/small-batch-1526-1527-1504

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Four audited-and-confirmed open issues, fixed in one batch (every fix verified against WSL GNU live probes + new unit cases):

Unit tests: hostname 11/11, diff 42/42, ls 171/171, grep green (new cases for all four). Full method and evidence in the commit message.

Context: found and confirmed by the audit sweep (branch audit/full-sweep, AUDIT-REPORT.md) — all four reproduced against GNU before fixing.

caomengxuan666 and others added 2 commits November 7, 2026 08:59
… clamps, #1504 ls COLUMNS, #1516 grep --color usage

hostname (#1526): -F/--file reads the hostname from a file; the read
goes through the wide extended path (make_api_path_operand().extended)
- this also restores the shape #1528 regressed at hostname.cpp:133
back to a narrow ACP-decoded ifstream, matching dircolors/hexdump in
the same PR.

diff (#1527): OptionalUIntClamp lands in opt.cppm next to the #1528
design slot - overflow clamps to UINT64_MAX like the valued forms,
and an attached empty value ("--context=") stores 0, so GNU's "diff
runs, rc=1" shape replaces the old arg-error exit 2. --unified=/
--context=/-c<num>/-u<num> all covered.

ls (#1504): a non-tty run now honors COLUMNS for -C layout (GNU
priority: tty width > COLUMNS > default 80).

grep (#1516): an unrecognized --color/--colour value prints the full
usage on stdout with EXIT_SUCCESS, no diagnostic - grep.c's
COLOR_OPTION shape (covers --color=bogus and the attached empty
value, refining #1513).

Verification: hostname 11/11, diff 42/42, ls 171/171, grep unit tests
green (new cases for each fix); live probes vs WSL GNU grep/diffutils:
hostname -F accepts and returns 0, diff --unified=99999999999999999999
clamps and diffs, COLUMNS=40 ls -C lays out two columns, grep
--color=bogus -> usage on stdout rc=0.
The i18n-drift gate is a ratchet: deliberate new user-visible strings
record their growth in the same PR (check_i18n_drift.py --update-baseline).
The three keys are the GNU error shapes this PR introduces:
- legacy.904ac09da6d4d139 "diff: Try 'diff --help' for more information."
- legacy.9b28a3702b3d6726 "the specified hostname is invalid"
- legacy.c9d02dd126c4a836 "name too long"
Catalog translation sync follows at release via the tag-triggered
sync-i18n-catalog job. Local check now passes: i18n drift OK (24 recorded, none new).
@caomengxuan666

Copy link
Copy Markdown
Member Author

Captain review note — i18n-drift failure (now fixed on the branch).

The i18n-drift failure was real, not infra: this PR introduces three new user-visible strings, and the drift gate (a ratchet over scripts/i18n-drift-baseline.json) caught all three:

  • legacy.904ac09da6d4d139 — "diff: Try 'diff --help' for more information."
  • legacy.9b28a3702b3d6726 — "the specified hostname is invalid"
  • legacy.c9d02dd126c4a836 — "name too long"

Resolved via the gate's sanctioned in-PR path (scripts/check_i18n_drift.py --update-baseline), commit 3aef268 — the baseline now records 24 items, and the local check passes ("i18n drift OK, none new"). Catalog translation sync follows at release through the tag-triggered sync-i18n-catalog job. No code changed, only the baseline record.

Two non-blocking notes for the merge:

  1. The kDebianUsage block (hostname usage text) is a constexpr passed through std::string(...), so the extractor never sees it — no drift key, and the usage will stay English under zh-CN. Follow-up, not a merge blocker.
  2. The PR body has no "本 PR 删除了什么" section (the governance charter asks for one on every PR). The deletions here are replaced code (old -F rejection branch, old get_terminal_width return, old color-mode error, old -c/-u option type). Please carry that accounting into the merge body, with one Fixes #n line per issue (hostname: -F is advertised in help, rejected by the parser, and its read branch is dead code #1526, diff: optional context forms (--unified=/--context=, -c/-u) still error past UINT64_MAX — needs OptionalUIntClamp #1527, ls: COLUMNS env var ignored when stdout is not a terminal (GNU uses it as the width fallback) #1504, [A5-G17 residual] grep: an invalid --color value makes GNU print help to stdout and exit 0; ours errors #1516) — the PR body itself only references them, so they will not auto-close otherwise.

Code review itself: the four fixes read correctly against GNU (hostname read_file/set_name/check_name pipeline, diff optional-context clamp + --context= as 0, ls COLUMNS priority, grep --color usage on success), and the differential run is all green. Full verdict once CI on the new head confirms.

@caomengxuan666

Copy link
Copy Markdown
Member Author

Captain review — verdict: CAN MERGE.

I read the full diff (12 files, 1,011 lines) and CI on the new head
3aef268 is fully green, so both legs check out.

Content. The four fixes are sound against GNU, each with new unit
cases (hostname 11/11, diff 42/42, ls 171/171, grep green):

CI. The i18n-drift failure on the first head was real (3 new
legacy keys) and is resolved by the baseline update in 3aef268
(see my earlier comment 6700259353); the job is green on the new
head, as is the whole differential run (oracle, baseline,
baseline-growth, compare) and every CMake build including the
x64-default ctest job.

Notes for the merge (not blockers):

Merge decision is the user's / Windows side's — I am not merging.

@caomengxuan666

Copy link
Copy Markdown
Member Author

Captain dedup note — the ls (#1504) face of this PR

While reviewing the batch I found that PR #1505 (opened
2026-11-02, five days before this PR) already implements the #1504
ls COLUMNS face as a dedicated fix, and I have now reviewed it in
full: it is the more GNU-faithful of the two implementations. The
divergences are all in this PR's ls hunk, measured against GNU
coreutils 9.4 decode_line_length():

  1. COLUMNS is parsed with strtol(..., 10) here — GNU is base-0, so
    COLUMNS=0x20 (32) and COLUMNS=010 (8) diverge.
  2. An overflowing COLUMNS warns and falls back to 80 here — GNU
    treats too-large values as "no limit".
  3. -w 0 falls through to the terminal width here (the -w fetch
    is unchanged) — GNU reads it as "no limit".
  4. For -x, COLUMNS=0 reaches print_columns as width 0 and clamps
    to one column (one entry per line) — GNU lays out one unwrapped
    line. The no-limit handling here covers the -C path only.
  5. The invalid-COLUMNS warning uses ASCII quotes (already noted as
    [DIFFERS] in the code) — GNU emits locale quotes; ls: honor COLUMNS env when stdout is not a terminal; -w 0 = no limit (fixes #1504) #1505 emits
    the UTF-8 form.

#1505's CI is fully green after re-running an oracle job that had
failed on a savannah HTTP 500 (infrastructure).

Recommendation: merge #1505 for the ls face; rebase this PR onto
the result and drop the ls hunk (src/commands/ls.cpp width chain
and the ls COLUMNS tests) — the two will conflict there anyway. The
CAN MERGE verdict for this PR's other three fixes (hostname -F
#1526, diff clamp #1527, grep --color #1516) stands unchanged, and
the i18n-drift baseline fix already pushed here (3aef268) stays
valid for them.

@caomengxuan666
caomengxuan666 merged commit c418284 into main Nov 7, 2026
13 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 9, 2026
The i18n-drift gate is a ratchet: deliberate user-visible string changes
record their growth in the same PR (check_i18n_drift.py
--update-baseline), per the #1534 precedent. Verified clean at the base
revision (24 recorded, none new); this PR grew zh-CN extras by 10:

- command.pinky.option.lookup: the invented --lookup option is removed —
  coreutils 9.4 pinky declares no long options beyond --help/--version
  (src/pinky.c longopts), so the catalog key the old option carried is
  now extra.
- legacy.0dd8f6031bba80d5 '^[nN]', legacy.1171ad640b28c83c day list,
  legacy.1ba4ef81e33e6de8 month list, legacy.633616abe53daa05 abday
  list, legacy.918315ef66894645 'USD ', legacy.af63994c86017ab3 '$',
  legacy.af63a14c8601884b ',', legacy.af63ac4c86019afc '1',
  legacy.d4c4e1038c50071b '^[yY]': the locale keyword-value literals
  moved out of direct safePrintLn calls into the keyword_value()
  whitelist helper, so scripts/i18n_batch.py's extraction regex (which
  only scans literals sitting directly inside safePrint calls) no
  longer sees them. Runtime translation is unaffected — safePrintLn
  localizes by content digest (translate_legacy) whatever shape the
  argument takes — so the zh-CN catalog entries stay live; only their
  extraction visibility changed.

Catalog translation sync follows at release via the tag-triggered
sync-i18n-catalog job. Local check now passes: i18n drift OK (34
recorded, none new).

Refs #1488, #1462
caomengxuan666 added a commit that referenced this pull request Nov 10, 2026
…plets

Three CI findings from PR #1561's first run, each traced to root cause:

i18n-drift: the 25 new-drift rows are all stale zh-CN keys whose source
strings this PR deleted (the 10 C++ bodies + test_expr.hpp, incl.
command.readlink/realpath.error.file_name_too_long — the Rust
fsutil::reason statics replaced the keyed i18n::format calls). Verified
PR-introduced: main tip measures none of them (its CI is green), and the
catalog clone carries the keys for text my branch no longer produces.
Recorded as deliberate growth with check_i18n_drift.py
--update-baseline per the #1534/#1547 precedent; the eventual shrink is
the catalog cleanup batch in unixwin/winuxcmd-i18n.

baseline (GNU master differential), 2 real mismatches vs the live oracle:
- mkdir -m 888 printed the usage Try-hint; GNU mkdir.c:290 treats an
  invalid mode as a runtime operand error - one stderr line, no hint.
  mkdir.rs writes the line directly now.
- test -f /dev/null returned 0: the operand reaches the library as the
  NUL DOS device and metadata() succeeds on it; -f now rejects DOS char
  devices (GNU: char device is not a regular file, rc 1).

build-windows x64 ctest, 4 symlink rows the local runner skipped
(no symlink privilege) that the CI runner executes:
- readlink -f / realpath default / realpath -m on a dangling leaf link
  (dang -> z_absent_tgt) now resolve the leaf symlink to its target's
  path (<parent>/z_absent_tgt, rc 0) instead of echoing the link name -
  AllButLast splices the read_link target onto the canonical parent and
  folds it lexically; NoCheck does the same over the -m walk; -e keeps
  failing (probed GNU 9.4). canon unit test pins the class where
  symlinks are creatable, skips where they are not.
- realpath --relative-to: the common-prefix walk compared components
  case-sensitively, so the CI runner's lowercase-drive ctx.cwd ("d:\...")
  never matched the canonicalized target's "D:\..." and the output fell
  back to absolute. Component comparison is now case-insensitive
  (Windows path spellings are case-variants).

pgrep_inverse_excludes_matches failed once on CI and passes on rerun -
the #1553 pid-flake family, unrelated.

Refs #1488
caomengxuan666 added a commit that referenced this pull request Nov 10, 2026
…plets

Three CI findings from PR #1561's first run, each traced to root cause:

i18n-drift: the 25 new-drift rows are all stale zh-CN keys whose source
strings this PR deleted (the 10 C++ bodies + test_expr.hpp, incl.
command.readlink/realpath.error.file_name_too_long — the Rust
fsutil::reason statics replaced the keyed i18n::format calls). Verified
PR-introduced: main tip measures none of them (its CI is green), and the
catalog clone carries the keys for text my branch no longer produces.
Recorded as deliberate growth with check_i18n_drift.py
--update-baseline per the #1534/#1547 precedent; the eventual shrink is
the catalog cleanup batch in unixwin/winuxcmd-i18n.

baseline (GNU master differential), 2 real mismatches vs the live oracle:
- mkdir -m 888 printed the usage Try-hint; GNU mkdir.c:290 treats an
  invalid mode as a runtime operand error - one stderr line, no hint.
  mkdir.rs writes the line directly now.
- test -f /dev/null returned 0: the operand reaches the library as the
  NUL DOS device and metadata() succeeds on it; -f now rejects DOS char
  devices (GNU: char device is not a regular file, rc 1).

build-windows x64 ctest, 4 symlink rows the local runner skipped
(no symlink privilege) that the CI runner executes:
- readlink -f / realpath default / realpath -m on a dangling leaf link
  (dang -> z_absent_tgt) now resolve the leaf symlink to its target's
  path (<parent>/z_absent_tgt, rc 0) instead of echoing the link name -
  AllButLast splices the read_link target onto the canonical parent and
  folds it lexically; NoCheck does the same over the -m walk; -e keeps
  failing (probed GNU 9.4). canon unit test pins the class where
  symlinks are creatable, skips where they are not.
- realpath --relative-to: the common-prefix walk compared components
  case-sensitively, so the CI runner's lowercase-drive ctx.cwd ("d:\...")
  never matched the canonicalized target's "D:\..." and the output fell
  back to absolute. Component comparison is now case-insensitive
  (Windows path spellings are case-variants).

pgrep_inverse_excludes_matches failed once on CI and passes on rerun -
the #1553 pid-flake family, unrelated.

Refs #1488
@caomengxuan666
caomengxuan666 deleted the fix/small-batch-1526-1527-1504 branch November 18, 2026 05:50
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