Skip to content

WIP: file/info tools — cmp, du, install, mktemp, truncate, cksum GNU alignment - #1405

Merged
caomengxuan666 merged 9 commits into
mainfrom
fix/winx4-file
Oct 27, 2026
Merged

caomengxuan666 merged 9 commits into
mainfrom
fix/winx4-file

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

WIP draft from the winx4-file fix cluster (file/info tools family). All six issues are fixed, one commit per issue, on top of main @ a104bb2.

Fixes #1347
Fixes #1351
Fixes #1357
Fixes #1358
Fixes #1360
Fixes #1362

Progress

Notes for reviewers

  • cmp: suffixed byte counts rejected, --silent missing, diagnostics doubled/misdirected, EOF report on the wrong stream #1347 item 5 adjudicated against the oracle: the issue text expects an extra Bad file descriptor line and exit 2 for cmp - f2 with empty stdin; GNU diffutils 3.10 locally prints only the EOF line and exits 1 in all stdin forms, so the fix follows the oracle. One pre-existing test that pinned the EOF report on stdout was corrected to stderr per this issue.
  • Known residual, deliberately not in this PR: du --inodes directory totals are one short of GNU (a directory does not count itself; fixture {x, y→x, z} prints 2 vs GNU 3). The one-line fix is identified in the cluster report; it was withheld because its verification build could not be obtained (shared build-slot starvation), and this line ships verified-only.
  • install: --backup value abbreviations and VERSION_CONTROL remain unsupported — shared with cp's parser, mirrored deliberately.
  • No local-build shims are in these commits: each commit contains only the command source and its unit tests (12 files total).

caomengxuan666 and others added 7 commits October 26, 2026 17:08
…orts with GNU (#1347)

- Byte-count suffixes follow the GNU table (kB/KB=1000, K/M/G/...=1024
  powers, KiB/MiB/...; c/w/b/B and lowercase m/g/t/p/e rejected), and
  leading whitespace in counts is skipped.
- Invalid counts report the full raw argument:
  invalid --bytes value '<raw>' / invalid --ignore-initial value '<raw>',
  followed by the Try line.
- --silent is accepted as its own option spelling.
- Operand open failures use a single 'cmp: ' prefix with the GNU
  reason (Is a directory / No such file or directory / Permission
  denied) and exit 2.
- The EOF report goes to stderr: ', line N' when the shorter side
  ends at a newline, ', in line N' otherwise; the -l form carries no
  line part.  One pre-existing test pinned the report on stdout and
  is corrected to stderr per this issue.

Regression tests: tests/unit/cmp (issue1347_*).
- Remove both sites that multiplied a file's size by its hard-link
  count.  Without -l a multiply-linked file now counts once at face
  value; with -l every encounter counts once at face value.
- Every counted file registers its inode in the run-wide seen set
  (previously only files with nlinks > 1 did), so a later operand
  naming an already-counted file is skipped like GNU — including
  'du d d/x' and grand totals.
- --inodes accumulation is mode-aware: each counted encounter adds
  exactly one; byte accumulation no longer leaks into inode totals.

Regression tests: tests/unit/du (issue1351_*).
- Split -b/--backup like cp: -b is a flag, --backup takes an optional
  value with the full control vocabulary (none/off, numbered/t,
  existing/nil, simple/never); suffix resolution is -S, then
  SIMPLE_BACKUP_SUFFIX, then '~'.  Numbered backups are 'bk.~1~'
  style (first free N); 'existing' upgrades to numbered when a
  '.~1~' backup is present.  Previously every backup was named
  'bk~' regardless of --backup=numbered.
- Source validation (cannot stat / omitting directory) now runs
  before any backup is created, so a directory source no longer
  leaves a spurious backup behind.
- A failed strip is no longer swallowed: report 'install: strip
  process terminated abnormally' (plus 'install: cannot run
  <prog>: No such file or directory' when the strip program cannot
  be run), remove the destination, and exit 1.

Regression tests: tests/unit/install (issue1357_*).
)

- More than one template operand now fails with
  'mktemp: too many templates' plus the Try line, creates nothing,
  and is checked before suffix validation (previously the extra
  templates were silently ignored).
- With --suffix, the template itself must end in X
  ('with --suffix, template <tpl> must end in X') and its own
  trailing X-run must be at least 3 — X's contributed by the suffix
  never count; the error quotes the composed template+suffix
  string.  Without --suffix, a run of at least 3 X's anywhere in
  the final component is required, as GNU does.

Regression tests: tests/unit/mktemp (issue1358_*).
parse_size now skips leading whitespace, and whitespace again after
the <, >, / and % mode characters — but not after a + or - sign.
The invalid-size diagnostic quotes the remainder after the skipped
leading whitespace with any sign retained (' 5x' -> '5x',
'+ 5' -> '+ 5', '<' -> '').

Regression tests: tests/unit/truncate (issue1360_*).
Replace the unordered has/has option pair for --binary/--text with
an md5sum-style scan of the parser occurrences in argv order, so
'cksum -b -t' and 'cksum -t -b' no longer produce identical output:
the last of -b/-t decides, validation ('--text mode is only
supported with --untagged') applies to the effective value, and
tagged output follows the winner.

Regression tests: tests/unit/cksum (issue1362_*).
# Conflicts:
#	src/commands/du.cpp
#	tests/unit/du/du_unit_test.cpp
#	tests/unit/mktemp/mktemp_unit_test.cpp
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 27, 2026 06:47
@caomengxuan666

Copy link
Copy Markdown
Member Author

Verified post-merge (origin/main @ 1854504): MSVC Debug build green; du/cmp/install/mktemp/truncate/cksum unit tests 184/186 with only the two issue_1288 LongPathsEnabled=0 baseline failures; full ctest 3262 — 11 residuals are the environment-bound baseline set plus one timing flake (tail.tail_repeated_pid_waits_until_all_processes_exit, 3/3 on immediate rerun).

du.cpp merge adjudication (#1372 x #1351): GNU coreutils du.c counts inodes per encounter (duinfo_set sets inodes=1 unconditionally; dedup happens in the traversal layer, and -l only disables that dedup — it never multiplies by the link count). The merged code keeps main's entry_count structure (#1372: inode mode contributes counts, byte size contributes nothing) and replaces the --count-links nlink multiplication with branch #1351's one-per-encounter rule; get_hard_link_count became dead code and was removed. Both sides' tests pass unchanged (62 du tests green), including du --inodes -l -c f h → 2 total.

Test-file conflicts (du/mktemp) were tail interleaving; every test function is byte-identical to one parent side (62 and 18 tests respectively).

i18n: en adds cmp --silent, install -b, install strip-abnormal-exit, mktemp too-many-templates keys; drops 3 superseded install/cmp diagnostics. Synced on winuxcmd-i18n sync/winx4-file-i18n (zh-CN translated, VERSION 0.6.30).

@caomengxuan666
caomengxuan666 merged commit f31fb58 into main Oct 27, 2026
3 of 4 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/winx4-file branch October 27, 2026 07:38
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
fix: repair conflict-marker pollution from the #1405/#1409 integration merges
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment