Repository navigation
WIP: file/info tools — cmp, du, install, mktemp, truncate, cksum GNU alignment - #1405
Conversation
…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
|
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). |
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
--silentmissing, diagnostics doubled/misdirected, EOF report on the wrong stream #1347 cmp (c96a43a) — GNU suffix grammar, count whitespace, invalid-value diagnostics,--silent, single-prefix open errors, EOF report on stderr with, line N/, in line Nforms-lmultiplies a file's usage by its link count; operands that are links to the same inode are double-counted #1351 du (bfc6d5a) — hard links counted once at face value (never scaled by link count), run-wide inode dedup for operands, mode-aware--inodesaccumulationbk~notbk.~1~), a failing --strip-program is silently ignored, directory sources are misdiagnosed #1357 install (c3e5807) — GNU backup control/naming (bk.~1~,-S>SIMPLE_BACKUP_SUFFIX>~), source validation before backup, strip failures are loud (message + dest removed + exit 1)too many templates(checked before suffix validation),--suffixX-run rules-svalues with leading whitespace are rejected (GNU's xstrtol skips it) #1360 truncate (40b6470) — leading whitespace in--sizeper GNU-b/-tare resolved order-blind (-talways wins) — GNU is last-occurrence-wins #1362 cksum (557c3ee) —-b/-torder-sensitive, last spelling winstests/unit/(names carryissueNNNNprefixes) — pending MSVC CI on this PRNotes for reviewers
--silentmissing, diagnostics doubled/misdirected, EOF report on the wrong stream #1347 item 5 adjudicated against the oracle: the issue text expects an extraBad file descriptorline and exit 2 forcmp - f2with 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.du --inodesdirectory 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.--backupvalue abbreviations andVERSION_CONTROLremain unsupported — shared with cp's parser, mirrored deliberately.