Repository navigation
fix(od): warn and fall back to the format-size LCM for a non-multiple -w width - #1951
Merged
Merged
Conversation
caomengxuan666
added a commit
to unixwin/winuxcmd-i18n
that referenced
this pull request
Nov 28, 2026
…ERSION to 0.6.54 (#42) Companion to unixwin/WinuxCmd#1951 (Refs unixwin/WinuxCmd#1943).
This was referenced Nov 28, 2026
Closed
caomengxuan666
added a commit
that referenced
this pull request
Nov 30, 2026
* rust2(port+wire): cat -> rust2 library + bridge (#1488) * fix(cat): route /dev/stdin family operands to stdin * fix(cat): honor WINUX_SHELL_GLOB=done, trailing-slash dir, and dir-on-stdin (#1803) * fix(ls): keep printable Unicode literal without POSIX locale (#1883) Windows filenames cross the narrow boundary as UTF-8 regardless of the legacy system locale, while interactive ls defaults to shell-escape quoting. Treating an unset POSIX locale as the C locale made ordinary CJK names render as octal byte splices for typical Windows users. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(ls): merge adjacent $'...' segments in shell-escape quoting (Fixes #1890) * fix(ptx): align fallback context truncation to UTF-8 char boundaries * fix(csplit): preserve trailing literals and UTF-8 in suffix format * fix(fold): parse numeric width from current index in clustered short options * fix(od): mask high-order bit in named character output (-a / -t a) * fix(ptx): slice context and fallback truncations on raw bytes like GNU * docs: adopt all-contributors, add dingyi580, ShiomiHC, qwased * fix(canon): realpath -m relative .. ascends from cwd again (Refs #1908) (#1918) * fix(winux-regex): restore ranges after the first in character classes (#1919) parse_char_class's is_range required prev_takes_range, so every range after the first in a bracket expression (or after a POSIX class / collating element) degraded to literal members: [A-Za-z] lost a-z, [A-Za-z_]+ silently mis-matched, [[:digit:]a-f] lost a-f. Regression introduced in 1.2.2 (1.2.1 matches GNU grep 3.12 / sed 4.9). Drop the prev_takes_range requirement from is_range (one line). The flag's legitimate use — the Invalid-range-end check for [a-c-e], [[:alpha:]-9], [[.a.]-z] — is untouched, and those shapes still error. New pins in tests/issue1911_ranges.rs (14): multi-range classes in both orders, range after POSIX class, negated multi-range, three ranges, -i multi-range, BRE form, matches_entire (find -regex face), plus the five regression faces above and [a-c-] / []-a]. Refs #1911 UNVERIFIED-BY-CAPTAIN * fix(od): warn and fall back to the format-size LCM for a non-multiple -w width (#1951) Refs #1943 * cp: -n is I_ALWAYS_NO per pristine GNU 9.4 (#1879) -n mapped to Interactive::AlwaysNo (cp.c:1070) instead of the Ubuntu .deb's silent AlwaysSkip: an existing destination now reports 'not replacing <dst>' and fails the file (copy.c:2438), a fresh copy under -n prints nothing, and the .deb-only deprecation warning is gone (no_clobber_seen deleted; make_backups added for the cp.c:1220 --backup/--no-clobber mutual exclusion, set by -b/--backup and -S/--suffix per cp.c:1027/1191). --update=none keeps the silent AlwaysSkip form. New i18n keys: command.cp.error.not_replacing, command.cp.error.backup_and_no_clobber (mv precedent). Refs #1879 (not Fixes). * test(gate): cp32/cp34/cp39 record-only — gate GNU side is the patched .deb The three -n-final rows were calibrated against the WSL distro's Ubuntu .deb cp 9.4, whose -n is patched to a silent rc-0 skip. The pristine coreutils 9.4 tarball oracle (this project's standard) prints "cp: not replacing '<dst>'" and exits 1 for exactly these combinations (-n, -nv, -nv --update=all, -v -i -n), matching the port after this PR. The rows stay as record-only (note) so both sides keep being measured without gating on the .deb divergence. * fix(cp): --parents no longer creates the bare drive designator in the cwd (Refs #1980) Refs #1980 (not Fixes). The --parents intermediate loop walked every '\\' prefix of the whole destination path, so for a backslash drive-absolute destination the first prefix created was the bare drive designator ("C:"). Since #1874 a bare "C:" folds to the relative name "C<U+F03A>" and landed as a stray directory in the cwd — silent (copy correct, rc 0), and it fired even when no intermediate directory needed creating, including $TEMP-derived destinations. GNU's make_dir_parents_private creates only below the destination, and the destination itself is required to exist (--parents, #1066), so none of its prefixes ever needs creating here: start the scan at destPath.size(). The #1874 fold itself is untouched (the bare-"D:"-is-a-relative-name contract is deliberate). Pin: cp_parents_backslash_drive_dest_leaves_no_drive_dir — the reporter's 4-case repro verbatim (backslash drive-absolute dest with/without trailing backslash, forward-slash control, no --parents control) plus a $TEMP-derived destination case; each asserts the copy, rc 0, and that the cwd listing is unchanged. * fixup: EXPECT_EQ only takes strings in the test framework The five cwd-listing assertions used EXPECT_EQ on two std::set<std::string> values; wctest::expect_eq_impl only accepts strings (C2664 on the x64 default leg). Switch them to EXPECT_TRUE(set == set). No production code touched. --------- Co-authored-by: caomengxuan666 <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: dingyi580 <[email protected]>
caomengxuan666
added a commit
that referenced
this pull request
Nov 30, 2026
* test: pin #1874 per-component carrier-colon operand shapes Fail-first pins for the per-component fold contract: winux-core unit pins (non-final components, ADS-shaped spellings, mid-path designator shapes, bare D: as a relative colon name), canon boundary pins through prepare_operand, and C++ ls/stat applet pins against an on-disk carrier tree. The bare-D: and canon pins are re-baselined to the #1874 contract ruled with the rubash #4198 caliber and probed against Git Bash on a real host. * fix(path): fold carrier colons per component in both fold twins (#1874) fold_carrier_colons (winux-core) and fold_carrier_colons_w (native_path.cppm) encoded only the final component, so operands with a literal colon in a non-final component (x:y/z, ./x:y/z, C:\x:y\z) never resolved the carrier tree the shell creates. Both folds now encode every component, byte-identically: the one exemption is the path's own drive designator in its absolute form (D:\ / D:/); a bare D: is a relative colon name and folds like D:name (MSYS contract, probed against Git Bash); designator-shaped components mid-path fold as ordinary components; verbatim/device spellings keep passing through untouched. * rust2(port+wire): uniq -> rust2 library + bridge (#1488) * fix(uniq): align open_write_operand and invalid_option signatures * fix(uniq): use u32 CmdResult and winux_core::test_support in tests * fix(uniq): fix -1 +1 test assertion and support -D5 cluster digits * fix(ls): keep printable Unicode literal without POSIX locale (#1883) Windows filenames cross the narrow boundary as UTF-8 regardless of the legacy system locale, while interactive ls defaults to shell-escape quoting. Treating an unset POSIX locale as the C locale made ordinary CJK names render as octal byte splices for typical Windows users. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(ls): merge adjacent $'...' segments in shell-escape quoting (Fixes #1890) * fix(ptx): align fallback context truncation to UTF-8 char boundaries * fix(csplit): preserve trailing literals and UTF-8 in suffix format * fix(fold): parse numeric width from current index in clustered short options * fix(od): mask high-order bit in named character output (-a / -t a) * fix(ptx): slice context and fallback truncations on raw bytes like GNU * docs: adopt all-contributors, add dingyi580, ShiomiHC, qwased * fix(canon): realpath -m relative .. ascends from cwd again (Refs #1908) (#1918) * fix(winux-regex): restore ranges after the first in character classes (#1919) parse_char_class's is_range required prev_takes_range, so every range after the first in a bracket expression (or after a POSIX class / collating element) degraded to literal members: [A-Za-z] lost a-z, [A-Za-z_]+ silently mis-matched, [[:digit:]a-f] lost a-f. Regression introduced in 1.2.2 (1.2.1 matches GNU grep 3.12 / sed 4.9). Drop the prev_takes_range requirement from is_range (one line). The flag's legitimate use — the Invalid-range-end check for [a-c-e], [[:alpha:]-9], [[.a.]-z] — is untouched, and those shapes still error. New pins in tests/issue1911_ranges.rs (14): multi-range classes in both orders, range after POSIX class, negated multi-range, three ranges, -i multi-range, BRE form, matches_entire (find -regex face), plus the five regression faces above and [a-c-] / []-a]. Refs #1911 UNVERIFIED-BY-CAPTAIN * fix(od): warn and fall back to the format-size LCM for a non-multiple -w width (#1951) Refs #1943 * cp: -n is I_ALWAYS_NO per pristine GNU 9.4 (#1879) -n mapped to Interactive::AlwaysNo (cp.c:1070) instead of the Ubuntu .deb's silent AlwaysSkip: an existing destination now reports 'not replacing <dst>' and fails the file (copy.c:2438), a fresh copy under -n prints nothing, and the .deb-only deprecation warning is gone (no_clobber_seen deleted; make_backups added for the cp.c:1220 --backup/--no-clobber mutual exclusion, set by -b/--backup and -S/--suffix per cp.c:1027/1191). --update=none keeps the silent AlwaysSkip form. New i18n keys: command.cp.error.not_replacing, command.cp.error.backup_and_no_clobber (mv precedent). Refs #1879 (not Fixes). * test(gate): cp32/cp34/cp39 record-only — gate GNU side is the patched .deb The three -n-final rows were calibrated against the WSL distro's Ubuntu .deb cp 9.4, whose -n is patched to a silent rc-0 skip. The pristine coreutils 9.4 tarball oracle (this project's standard) prints "cp: not replacing '<dst>'" and exits 1 for exactly these combinations (-n, -nv, -nv --update=all, -v -i -n), matching the port after this PR. The rows stay as record-only (note) so both sides keep being measured without gating on the .deb divergence. * fix(cp): --parents no longer creates the bare drive designator in the cwd (Refs #1980) Refs #1980 (not Fixes). The --parents intermediate loop walked every '\\' prefix of the whole destination path, so for a backslash drive-absolute destination the first prefix created was the bare drive designator ("C:"). Since #1874 a bare "C:" folds to the relative name "C<U+F03A>" and landed as a stray directory in the cwd — silent (copy correct, rc 0), and it fired even when no intermediate directory needed creating, including $TEMP-derived destinations. GNU's make_dir_parents_private creates only below the destination, and the destination itself is required to exist (--parents, #1066), so none of its prefixes ever needs creating here: start the scan at destPath.size(). The #1874 fold itself is untouched (the bare-"D:"-is-a-relative-name contract is deliberate). Pin: cp_parents_backslash_drive_dest_leaves_no_drive_dir — the reporter's 4-case repro verbatim (backslash drive-absolute dest with/without trailing backslash, forward-slash control, no --parents control) plus a $TEMP-derived destination case; each asserts the copy, rc 0, and that the cwd listing is unchanged. * fixup: EXPECT_EQ only takes strings in the test framework The five cwd-listing assertions used EXPECT_EQ on two std::set<std::string> values; wctest::expect_eq_impl only accepts strings (C2664 on the x64 default leg). Switch them to EXPECT_TRUE(set == set). No production code touched. * rust2(port+wire): cat -> rust2 library + bridge (#1488) (#1882) * rust2(port+wire): cat -> rust2 library + bridge (#1488) * fix(cat): route /dev/stdin family operands to stdin * fix(cat): honor WINUX_SHELL_GLOB=done, trailing-slash dir, and dir-on-stdin (#1803) * fix(ls): keep printable Unicode literal without POSIX locale (#1883) Windows filenames cross the narrow boundary as UTF-8 regardless of the legacy system locale, while interactive ls defaults to shell-escape quoting. Treating an unset POSIX locale as the C locale made ordinary CJK names render as octal byte splices for typical Windows users. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(ls): merge adjacent $'...' segments in shell-escape quoting (Fixes #1890) * fix(ptx): align fallback context truncation to UTF-8 char boundaries * fix(csplit): preserve trailing literals and UTF-8 in suffix format * fix(fold): parse numeric width from current index in clustered short options * fix(od): mask high-order bit in named character output (-a / -t a) * fix(ptx): slice context and fallback truncations on raw bytes like GNU * docs: adopt all-contributors, add dingyi580, ShiomiHC, qwased * fix(canon): realpath -m relative .. ascends from cwd again (Refs #1908) (#1918) * fix(winux-regex): restore ranges after the first in character classes (#1919) parse_char_class's is_range required prev_takes_range, so every range after the first in a bracket expression (or after a POSIX class / collating element) degraded to literal members: [A-Za-z] lost a-z, [A-Za-z_]+ silently mis-matched, [[:digit:]a-f] lost a-f. Regression introduced in 1.2.2 (1.2.1 matches GNU grep 3.12 / sed 4.9). Drop the prev_takes_range requirement from is_range (one line). The flag's legitimate use — the Invalid-range-end check for [a-c-e], [[:alpha:]-9], [[.a.]-z] — is untouched, and those shapes still error. New pins in tests/issue1911_ranges.rs (14): multi-range classes in both orders, range after POSIX class, negated multi-range, three ranges, -i multi-range, BRE form, matches_entire (find -regex face), plus the five regression faces above and [a-c-] / []-a]. Refs #1911 UNVERIFIED-BY-CAPTAIN * fix(od): warn and fall back to the format-size LCM for a non-multiple -w width (#1951) Refs #1943 * cp: -n is I_ALWAYS_NO per pristine GNU 9.4 (#1879) -n mapped to Interactive::AlwaysNo (cp.c:1070) instead of the Ubuntu .deb's silent AlwaysSkip: an existing destination now reports 'not replacing <dst>' and fails the file (copy.c:2438), a fresh copy under -n prints nothing, and the .deb-only deprecation warning is gone (no_clobber_seen deleted; make_backups added for the cp.c:1220 --backup/--no-clobber mutual exclusion, set by -b/--backup and -S/--suffix per cp.c:1027/1191). --update=none keeps the silent AlwaysSkip form. New i18n keys: command.cp.error.not_replacing, command.cp.error.backup_and_no_clobber (mv precedent). Refs #1879 (not Fixes). * test(gate): cp32/cp34/cp39 record-only — gate GNU side is the patched .deb The three -n-final rows were calibrated against the WSL distro's Ubuntu .deb cp 9.4, whose -n is patched to a silent rc-0 skip. The pristine coreutils 9.4 tarball oracle (this project's standard) prints "cp: not replacing '<dst>'" and exits 1 for exactly these combinations (-n, -nv, -nv --update=all, -v -i -n), matching the port after this PR. The rows stay as record-only (note) so both sides keep being measured without gating on the .deb divergence. * fix(cp): --parents no longer creates the bare drive designator in the cwd (Refs #1980) Refs #1980 (not Fixes). The --parents intermediate loop walked every '\\' prefix of the whole destination path, so for a backslash drive-absolute destination the first prefix created was the bare drive designator ("C:"). Since #1874 a bare "C:" folds to the relative name "C<U+F03A>" and landed as a stray directory in the cwd — silent (copy correct, rc 0), and it fired even when no intermediate directory needed creating, including $TEMP-derived destinations. GNU's make_dir_parents_private creates only below the destination, and the destination itself is required to exist (--parents, #1066), so none of its prefixes ever needs creating here: start the scan at destPath.size(). The #1874 fold itself is untouched (the bare-"D:"-is-a-relative-name contract is deliberate). Pin: cp_parents_backslash_drive_dest_leaves_no_drive_dir — the reporter's 4-case repro verbatim (backslash drive-absolute dest with/without trailing backslash, forward-slash control, no --parents control) plus a $TEMP-derived destination case; each asserts the copy, rc 0, and that the cwd listing is unchanged. * fixup: EXPECT_EQ only takes strings in the test framework The five cwd-listing assertions used EXPECT_EQ on two std::set<std::string> values; wctest::expect_eq_impl only accepts strings (C2664 on the x64 default leg). Switch them to EXPECT_TRUE(set == set). No production code touched. --------- Co-authored-by: caomengxuan666 <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: dingyi580 <[email protected]> --------- Co-authored-by: caomengxuan666 <[email protected]> Co-authored-by: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: dingyi580 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1943
根因
od的--width解析(rust2/crates/winux-cmds/src/od.rs)此前没有任何按格式单位大小的整除校验:宽度原样进入OdConfig作 bytes_per_line 使用。因此-w5(默认格式单位 2 字节)时 winuxcmd 既不警告、也不回退,按字面宽度 5 输出,与 GNU 不符。GNU 真规则(coreutils 9.4
od.c)od.cmain() 1921–1946 +get_lcm()1311–1318:指定宽度时,合法 ⟺width % lcm(各格式 sizeof) == 0;否则印od: warning: invalid width N; using <lcm> instead并令 bytes_per_block = lcm 本身,退出码仍为 0。注意回退值是 lcm 本身、不是「不大于请求值的最大合法宽度」——反例:-t d8 -w5GNU 用 8(大于请求值)。改动
rust2/crates/winux-cmds/src/od.rs(+83/−1):记录width_specified,在OdConfig构造前的单一校验点上以现成type_size()对格式集折叠 lcm(checked 运算);不整除时经现有od: {}+tr!面印警告并回退width = lcm。新钉 3 条(-w5、-w7、-w5 -t d8 → using 8)+ 对照钉 1 条。scripts/i18n-drift-baseline.json(+2/−1):--update-baseline记录——新键command.od.error.invalid_width_fallback在 catalog 落库前先记为 zh-CN missing(193 项),与既往各波同形。catalog/载荷 3 文件(新):od-width-en-additions.json(英文字面)、od-width-zh-patch.json(中文译文)、od-width-validate.txt(validate 输出valid),已由队长在 winuxcmd-i18n 仓落库:i18n(od): add command.od.error.invalid_width_fallback (zh-CN), bump VERSION to 0.6.54 winuxcmd-i18n#42(zh-CN catalog +1 键、VERSION 0.6.53 → 0.6.54),建议与本 PR 同波合入。本 PR 删除了什么
无删除。旧代码不存在宽度校验路径;本 PR 只在 od 唯一的宽度处理流(解析 → OdConfig)上插入 GNU 同规校验,未引入 shim、桥或第二走法。净行 delta(git-diff 口径):od.rs 净 +82、baseline 净 +1、catalog 新文件 3 个。
证据(devin-windows,windows-gnu 工具链,前台跑)
cargo test -p winux-cmds od::tests= 40 passed / 3 failed,红的恰是 3 条新钉;改实现后 43 passed / 0 failed。cargo test -p winux-cmds= 1102 passed / 1 failed;唯一红df::tests::type_filters已在 pristine base 上复证同签名同位置失败,为本机环境红(CI msvc 绿,2026-11-28 已裁定),与本改动无关。--update-baseline后复跑i18n drift OK (193 recorded item(s), none new);英中对 validate =valid。LC_ALL=C.UTF-8,21 例 ×(stdout/stderr/rc)= 63 文件逐字节全等(14 警告例 + 7 静默对照例),rc 全 0。captain-verified on devin-windows; CI pending