Repository navigation
#1488 wiring wave1 remainder: 10 commands to rust2, C++ bodies deleted - #1561
Merged
Merged
Conversation
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
force-pushed
the
rust2/wire-wave1
branch
3 times, most recently
from
November 10, 2026 18:08
74f82fd to
af5e55c
Compare
The rust2 bridge drained Rust stdout/stderr through safePrint / safeErrorPrint, which apply the legacy i18n catalog lookup (translate_legacy) to the whole payload. For true/false (no output) that was unobservable, but a data-printing command — basename's result line, printenv's value, pwd's path — must reach the handle byte-for-byte: an entry whose FNV-1a key hashes to the output bytes would otherwise silently replace command DATA. The #1533 length gate only narrows the lookup; a data output path has to bypass translation entirely. Add safePrintRaw / safeErrorPrintRaw (mirrors of the translating writers minus translate_legacy, sharing capture handles, console/file detection, byte counting, SIGPIPE mapping and write-failure notes) and route the bridge's drain through them. - src/utils/console.cppm: add the two raw writers next to the UTF-8 overloads they mirror. - src/bridge/rust2_bridge.cppm: drain through the raw writers; comment states why translation must not apply here. Refs #1488
Probed against WSL coreutils 9.4 (script-file probes, symlinked dir so
the logical and physical spellings differ textually): `pwd -L` uses $PWD
verbatim only when it is absolute, contains no "." / ".." component, and
names the current directory. Redundant slashes are accepted and echoed
verbatim ("PWD=//tmp/x" -> "//tmp/x", "PWD=/tmp//x" -> "/tmp//x"), but
"PWD=<dir>/.", "PWD=<dir>/./", "PWD=<dir>/sub/.." all fall back to the
physical spelling silently. The Rust pwd_cmd only checked
absolute + same-dir, so it echoed such a PWD verbatim — a divergence the
gate table could not see (acceptance and fallback share rc 0; win-mode
rows never compare stdout).
- has_relative_components(): reject on any "." / ".." component, split
on both separators (Windows $PWD may carry either spelling).
- Unit tests lock the class: dot/dotdot PWD naming the same dir must
fall back; redundant-slash PWD stays verbatim.
The wired-product ctest slice (pwd_logical_ignores_pwd_environment_with
_dot_component / _dotdot_component) is the durable gate-b net for this
class; both go green with this fix.
Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is a single winux::rust2::run_command("pwd", ctx.raw_args) call; the
whole pwd_pipeline namespace (path-mode election, $PWD validation,
canonicalization) is deleted. REGISTER_COMMAND metadata stays
byte-identical (help/man/completion still render from it), and the
dispatcher's shared pre-handler machinery is untouched.
ctx.raw_args passes the operands verbatim because GNU pwd.c parses its
own argv (no getopt filtering in front of the library).
Three gates:
- gate a/c harness (build-vs exe vs baseline exe vs WSL coreutils 9.4):
GNU-gated 12/12 GREEN; r=c parity 1/12 unchanged from the pre-wiring
driver-vs-C++ ledger (the 11 win rows print each side's own scratch
dir as stdout — platform-form-bound, never gated).
- argument matrix (rust2/gate/wire/cmd-matrix.sh, new shared probe for
the wave): old vs new exe 22/22 rows byte-equal on rc+stdout+stderr
from one shared cwd; GNU rc parity 22/22 (covers --help/--version
sole vs embedded, -h, --bogus, -z, --, -, -L/-P orders,
POSIXLY_CORRECT, PWD shapes).
- ctest slice: 20/20 pwd tests pass (the two dot/dotdot $PWD tests are
green on top of the preceding rust2(pwd) component fix).
Refs #1488
…#1488) Probed against WSL coreutils 9.4 (printenv.c parses getopt_long(argc, argv, "+0", longopts)): the leading '+' ends option processing at the first non-option argument, so only the leading option run sees -0/--null and help/version. Two divergences hidden from the gate table (acceptance/fallback and option/operand share an rc; win rows never compare stdout): - `-0`/`--null` was rejected as a usage error; GNU terminates each printed value with NUL (`printenv -0 VAR` -> "hello\0", full dump NUL-separated too). - `--help`/`--version` were honored in any position; GNU honors them only before the first NAME — `printenv VAR --help` looks up a variable literally named "--help" (rc 1), as does `printenv VAR -0` with "-0". Unit tests lock both classes (NUL separators for value and dump forms; tokens after the first NAME are names). The product's dispatcher already mirrors the stop-at-first-operand boundary for interception (stop_options_after_positionals=1), so the wired handler sees the same token classes GNU's getopt delivers. Refs #1488
Probed against WSL coreutils 9.4: `printenv` with no NAME dumps the
whole environ as NAME=VALUE records ("SHELL=/bin/bash..."). The pilot
wrote only the value part — `for (_k, v) in entries()` dropped the
name — and the gate table could not see it: pe14 is a win row (stdout
recorded, never compared) and pe15 gates only the exit status.
Fix the record shape; unit test now asserts "AAA=1\nBBB=2\n" and the
NUL-separator dump "A1=1\0B2=2\0".
Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("printenv", ctx.raw_args) call; the
GetEnvironmentStringsW enumeration, the _wgetenv lookup path and the
separator helper are deleted. REGISTER_COMMAND metadata (synopsis, -0
option row) stays byte-identical.
ctx.raw_args passes operands verbatim: GNU printenv.c owns its
getopt("+0") run and the leading '+' stop-at-first-NAME boundary, which
the Rust library now implements itself (see the preceding rust2(printenv)
commits). Env values reach stdout through the bridge's raw writers, so a
variable's bytes are never catalog text.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): 20/20
GNU-gated GREEN; strict rows byte-for-byte on stdout. The three r=c:no
rows are explained: pe10 (old exe's _wgetenv was case-insensitive, a
documented C++ deviation the library does not inherit — r=g:yes),
pe14/pe15 (full-dump environments differ in harness-bound __RUBASH_*
/ PWD vars, unchanged from the pre-wiring ledger).
- argument matrix (cmd-matrix.sh printenv, one shared cwd): old vs new
rc 15/15, stderr 15/15, stdout 14/15 with the single diff being the
harness's own __RUBASH_FD_HANDLE_3 hex var; GNU rc parity 15/15
(covers -0/--null before and after operands, --help/--version sole
and embedded, --, -, unknown short/long, missing vars).
- ctest slice 9/9 pass.
Refs #1488
…options (#1488) The wave tables carried invented alias entries ("mul", "suf", "ze", "par", "mod", "verb", "can", "can-ex", "can-mis", "no-new") to fake getopt_long abbreviation, but the commands read only the canonical keys (value_of("suffix"), has("zero"), ...), so those spellings silently parsed as no-ops: `basename --suf .c /a/f.c` printed "f.c" (suffix dropped, multiple off — single-mode with operand 2 as suffix), `basename --ze -a x` ignored the NUL request. Probed against WSL coreutils 9.4: the abbreviations are getopt_long prefix matches (basename --mul/--suf/--ze all behave as --multiple/--suffix/--zero; --hel prints help; --vers prints version; `readlink --can x` is "option '--can' is ambiguous; possibilities: ..."; `--suf` with no value reports canonical "option '--suffix' requires an argument"; and --suffix with ANY value, even the empty one, implies multiple mode). Fix the invariant, not the symptom: - argopt resolves --name exactly the way getopt_long does — exact match wins, otherwise exactly one unambiguous-prefix candidate among the registered longs plus the virtual help/version; ambiguity is a usage error listing the possibilities; every match records under the spec's canonical long name. - Delete the fake alias entries from basename/dirname/realpath/mkdir/ rmdir/readlink tables; realpath's GNU --silent keeps its own entry and quiet now reads it. - basename: multiple = --multiple present OR --suffix present (any value) per the probed GNU rule. - Unit tests lock the class: abbreviation resolution, virtual help/version prefixes, canonical requires-argument wording, the basename spellings, empty-suffix-implies-multiple. Full gate re-run (31 case tables, driver vs baseline exe vs WSL coreutils 9.4): no new failures in any registered command; the only failing rows are getconf/hostname/id/uname, whose registry entries were never merged to main (pre-existing origin/main gap, 88 rows all rc=127 "unknown command" — out of this wave's scope). cmd-matrix.sh grows basename/dirname backslash-operand rows (a\b) to record the deliberate GNU alignment: GNU basename/dirname treat only '/' as a separator; the 1.x C++ applets also stripped '\', a documented deviation the library does not inherit. Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("basename", ctx.raw_args) call; the
whole basename_pipeline (option shaping, get_basename's separator walk,
the suffix/driver-letter special case) is deleted. REGISTER_COMMAND
metadata stays byte-identical.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): 30/30
GNU-gated GREEN, and r=c on every row — byte parity with the old exe.
- argument matrix (cmd-matrix.sh basename, one shared cwd): rc 23/23,
stderr 23/23, stdout 22/23; GNU rc parity 23/23. The one stdout diff
is the deliberate GNU alignment recorded by the a\b row: GNU treats
only '/' as a separator, the old C++ body also stripped '\' (matrix
rows /a/b/c were the same class — msys delivers them as A:\b\c in
argv, old stripped, new echoes; switched to relative rows so the
matrix carries exactly one intentional diff).
- ctest slice 16/16 pass. Six tests asserted the old backslash-stripping
on Windows-shaped operands; their expectations are now the GNU-pinned
bytes (whole backslash operand echoed; suffix removal is a
string-suffix rule on the unsplit name; empty -s/--suffix still
implies multiple; -z NUL form carries the backslash operand verbatim),
each probed against coreutils 9.4 before editing.
Depends on the preceding rust2(argopt) commit: --mul/--suf/--ze and
empty-suffix-implies-multiple come from the library fix, and two of the
previously failing ctest rows (abbreviated --suf/--ze long options) went
green with it.
Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("dirname", ctx.raw_args) call; the
whole dirname_pipeline (drive-prefix faces, root-length windows,
separator trimming) is deleted. REGISTER_COMMAND metadata stays
byte-identical.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): 22/22
GNU-gated GREEN, r=c on every row (byte parity with the old exe).
- argument matrix (cmd-matrix.sh dirname, one shared cwd): rc 17/17,
stderr 17/17, stdout 16/17; GNU rc parity 17/17. The one stdout diff
is the deliberate GNU alignment row (a\b): GNU separates on '/' only,
the old C++ body also stripped '\'.
- ctest slice 14/14 pass. Five tests asserted the Cygwin face (drive
prefixes, '\' separators, "//" preserved for //a); the expectations
are now the GNU-pinned bytes (backslash operands reduce to ".",
'C:/foo' keeps its drive prefix, "//a" folds to "/" while "//a/b"
keeps "//a", the -z form carries the reduced operands), each probed
against coreutils 9.4 before editing.
Refs #1488
) Probed against WSL coreutils 9.4 (readlink.c): - `-q`/`--quiet` and `-s`/`--silent` are accepted spellings of SILENT; the library rejected them as unknown options. Verbosity is LAST-WINS across -q/-s/-v (`-v -q` stays silent, `-s -v` reports) — readlink.c assigns an enum per occurrence; the pilot read only a "verbose" flag. - `-n -z` (either order) emits NO terminator: the NUL lives behind the same `if (! no_newline)` guard (readlink.c:162-168). The pilot rejected the combination with a usage error. - `-n` with MULTIPLE operands: the "ignoring --no-newline with multiple arguments" warning goes to stderr, no_newline is disabled, and the normal terminators are emitted; rc follows the per-operand results. Unit tests lock the class (all four silent spellings, both last-wins orders, single-operand -n/-z and the multi-operand warning). Refs #1488
GNU lib/canonicalize.c assembles the canonical name with '/' by construction (coreutils 9.4 probe under WSL: `readlink -f d/f.txt` -> '/tmp/.../d/f.txt', zero backslashes). The pilot returned the Windows resolver's '\' spelling, a divergence the gate table could not see (the canonicalize rows are exit-mode: stdout is recorded, never gated). A '\' separator also breaks the shell word arithmetic that consumes the output — the exact regression the product already fixed C++-side as #1491 (to_display_separators on the canonicalize modes only). Apply the same class fix on the rust2 side: canonicalize modes (-f/-e/ -m) render the resolved name with '/' separators; the no-mode form keeps printing the stored link target verbatim, like GNU areadlink. Refs #1488 #1491
) canonicalize_path_w resolves its operand through a fold chain the rust2 canon module lacked, so readlink -f/realpath diverged from the C++ resolver on the same spellings (the #850 family's "argv folded, resolver walked verbatim" shape): - /cygdrive/X (#1145, case-insensitive) and /mnt/X (#1172, case-sensitive literal; bare /mnt, /mnt/data, /mntcc never fold) fold onto the MSYS single-letter spelling; - the drive dialect /e/Data folds onto E:\Data (#1231); - literal colons in the final component fold onto the U+F03A carrier (#1283), with bare "D:" and verbatim/device spellings exempt. The chain runs on the trailing-separator-stripped operand, in the same order as the C++ boundary, before the mode walks. The shell-tree mapping (niubash#346) is inert without a configured shell root and is not carried. Unit tests pin the recognition edges byte-for-byte. Refs #1488 #1145 #1172 #1231 #1246 #1283
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("readlink", ctx.raw_args) call; the raw
reparse-buffer decode, the canonicalize resolver and the terminator
policy are deleted. REGISTER_COMMAND metadata (option table included)
stays byte-identical.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): 24/24
GNU-gated GREEN; the 14 r=c:no rows all reduce to the harness
self-path class (canonicalize of a relative operand prints each
side's own scratch dir; exit rows gate rc) — zero real diffs after
normalizing the side-specific directory prefix.
- argument matrix (cmd-matrix.sh readlink, one shared cwd): rc 19/19,
stdout 19/19, stderr 19/19 byte-equal old vs new (covers -n/-z/-f/-e/
-m/-q/-v orders, --help/--version embedded, missing operands).
- ctest slice 25/25 pass. Two tests (#1246 drive-dialect/cygdrive
operands) and the #1491 '/'-separator output class are green on top
of the preceding rust2(readlink)/rust2(canon) commits.
Refs #1488
Probed against WSL coreutils 9.4 and cross-checked with the 1.x applet's registered options: - "--silent" does not exist in realpath (rejected with "unrecognized option"); the entry I had carried was readlink's spelling leaking over. Removed. - -L/--logical and -P/--physical are accepted realpath.c mode-word spellings; added as accepted flags (the symlink-order refinement they select is a no-op on this resolver; probed rc/output contract equal to the default). - --no-symlinks is realpath.c's second spelling of -s/--strip; added and read together with strip. - -E/--canonicalize (all but the last must exist) is the 1.x applet's own extension ([EXT] in its option table, not in GNU); added mapping to the default mode so the wired exe keeps accepting it. Refs #1488
The 1.x C++ realpath passed 35 product tests the rust2 pilot failed; every gap is GNU-pinned (WSL coreutils 9.4 probes) and now ported: - mode word is LAST-WINS in argv order (`-e -m f` permissive, `-m -e f` demands existence; probed both directions); - the -m lexical walk prints the native '\' spelling over the FOLDED operand (drive dialect "E:\...\prog\absent.txt", bare "/x" -> "X:\", multi-letter "/nodrive" resolves under the cwd) — normalize_lex_native replaces the '/'-only string walker that stranded native forms; - existence modes reject over-NAME_MAX components with "File name too long" ([GNU] #370), mapped via ErrorKind::InvalidInput in reason(); - trailing separators: a MISSING leaf still resolves (the last-component exemption ignores slashes) while an existing non-directory leaf is ENOTDIR — the OS canonicalize fails on the separator itself, so the parent-walk exit judges the leaf explicitly; - traversing a regular file reports "Not a directory" even when the remaining component is last (the parent walk now checks is_dir); - empty --relative-to/--relative-base values are rejected once with the 1.x wording and rc 1, no operand output; - under -e BOTH bases must be directories ("Not a directory", rc 1); - --relative-base relativizes only BELOW the base (component-boundary check): outside targets keep their absolute form, --relative-to keeps relativizing. Unit tests cover the trailing-separator pair and the direct canonicalize_operand contract. Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("realpath", ctx.raw_args) call; the
canonicalization pipeline and the relativize step are deleted.
REGISTER_COMMAND metadata stays byte-identical.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): GNU-gated
GREEN, zero r=c:no rows.
- argument matrix (cmd-matrix.sh realpath, one shared cwd): rc 23/23,
stdout 23/23, stderr 23/23 byte-equal old vs new; GNU rc parity 23/23
(-e/-m/-s/-q/-z, --logical/--physical/--canonicalize-missing, both
relative options, --, -, -x, --bogus, embedded help/version).
- ctest slice 35/35 pass on top of the preceding rust2(realpath/canon)
semantics commit (mode word, ENAMETOOLONG, ENOTDIR walks, trailing
separators, base validation, below-only relativization, native -m
spellings).
Refs #1488
…#1488) Three GNU/product shapes the pilot lacked, each pinned by a wired-product ctest row: - -Z/--context accepted as the SELinux no-op flag (getopt gives the long form an optional value; the flag-shaped entry reproduces the pinned `mkdir -Z ctx_dir` shape, where ctx_dir is an operand). - #1231: the drive dialect operand ("/e/Data") lands on the OPERAND's drive, not the cwd's — canon::prepare_operand (now crate-visible) folds it for the filesystem walk while verbose/diagnostics keep the operand spelling; the folded bare root ("/e" -> E:\\) makes `mkdir -p /e` on an existing drive root a silent noop. - [GNU] mkdir.c make_ancestor: with -p, -m MODE applies to the leaf only; ancestors keep the default mode (was: applied to every component). Refs #1488 #1231
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("mkdir", ctx.raw_args) call; the
creation pipeline and the mode mapping are deleted. REGISTER_COMMAND
metadata stays byte-identical.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): GNU-gated
GREEN, zero r=c:no rows.
- argument matrix (cmd-matrix.sh mkdir, one shared cwd): rc 16/16,
stdout 16/16, stderr 16/16 byte-equal old vs new; GNU rc parity 16/16.
The matrix fixture now EXECUTES its per-case reset (a printf-only
stub left the first run's tree in place and manufactured File-exists
rows on the second side); readlink/realpath rows are unaffected.
- ctest slice 19/19 pass on top of the preceding rust2(mkdir)/
rust2(modemap) commits (-Z placeholder, operand-drive fold, -m
leaf-only with -p, symbolic modes against the a=rwx base).
Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("rmdir", ctx.raw_args) call; the removal
pipeline and the -p ancestor walk are deleted. REGISTER_COMMAND metadata
stays byte-identical.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): GNU-gated
GREEN, zero r=c:no rows.
- argument matrix (cmd-matrix.sh rmdir, one shared cwd): rc 16/16,
stdout 16/16, stderr 16/16 byte-equal old vs new; GNU rc parity 16/16
(missing operands, -p chains, --ignore-fail-on-non-empty with -p,
-v, --, --bogus, embedded help/version).
- ctest slice 13/13 pass on top of the preceding rust2(rmdir) --path
alias commit.
Refs #1488
Probed against WSL coreutils 9.4: `test --help x` and `test --version x`
report "missing argument after 'x'" (posixtest case 2 names the second
token, the only candidate binary operand) — the pilot emitted
"'--help': unary operator expected", naming the first token instead.
Every other small-n diagnostic shape already matched ("x --help",
"a -a", the `--foo` single-string form).
The three wired-product ctest rows that assert the exact stderr
(test_help_with_extra_operand_is_expression_error and friends) go green
with this fix.
Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: both handler bodies are single winux::rust2::run_command calls (test / [); the shared src/commands/test_expr.hpp parser and its stat() helpers are deleted with their only two consumers. REGISTER_COMMAND metadata (the operator option tables) stays byte-identical in both files. The pre-handler machinery is untouched and already GNU-shaped for these two: the dispatcher honors --help/--version only as the sole argument (help_version_only_when_sole_argument) and the option policy lets every unknown short/long token through as an operand, so ctx.raw_args is exactly the expression language GNU test.c parses. Three gates: - harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): test 45/45 and bracket 26/26 GNU-gated GREEN; zero r=c:no rows. - argument matrix (cmd-matrix.sh test and [, one shared cwd): test 24/24 rows and [ 16/16 rows byte-equal old vs new on rc+stdout+stderr; GNU rc parity 24/24 and 16/16 (expressions, -a/-o chains, !, -t, --, --bogus, embedded help/version, [ with and without the closing ]). - ctest slice 24/24 pass on top of the preceding rust2(test) 2-argument wording fix (the three help/version-with-extra-operand rows assert the GNU stderr bytes). Refs #1488
…1488) Probed against WSL coreutils 9.4: `test -o x` and `test -a x` report "'-o': unary operator expected" — the AND/OR operators in the operator position are diagnosed with the unary wording — while every other non-unary first token ("--help x", "--version x", "-eq x", "-nt x", "-zz x", the bare "1 2") reports "missing argument after '<second>'". The previous commit's blanket second-token rule lost the -a/-o branch; restore it alongside the missing-argument rule. Refs #1488
…1488) Probed against WSL coreutils 9.4: - the AND/OR operators are binops in the 3-argument form: `test a -a b` -> 0, `test a -a ''` -> 1, `test '' -o b` -> 0 (the pilot rejected "-a"/"-o" with "binary operator expected"); "==" is a binop too (`test abc == abc` -> 0). binary_operator gains the three arms and the >= 4-argument parser keeps the GNU precedence — -a tighter than -o, both looser than every comparison — so the primary-level binary form excludes them (parse_expr/parse_and own those levels). - the two-argument matrix rows `a -a` keep GNU's "missing argument after '-a'" (binop in the second slot), while "-a"/"-o" in the FIRST slot keep "'-a': unary operator expected" (`test -o x`). Gate table: ts43-help-flag moves strict -> note. GNU `test --help` prints nothing (rc 0, string-test of "--help"); the wired exe prints the WinuxCmd-branded sole-argument help — the deliberate product-wide dispatcher contract the 1.x applet also shipped (r=c parity holds, and the C++ unit tests assert the branded text). Case row regenerated via gate/gen-cases.py (only ts43 changed). Refs #1488
Mechanical replacement per rust2/REPLACEMENT-RECIPE.md: the handler body
is one winux::rust2::run_command("sync", ctx.raw_args) call; the
FlushFileBuffers walk and the operand glob expansion are deleted
(GNU never globs operands — the caller's shell does; a literal "st*"
reports "error opening 'st*'" on both sides, the matrix row pins it).
REGISTER_COMMAND metadata stays byte-identical.
Three gates:
- harness (build-vs exe vs baseline exe vs WSL coreutils 9.4): 22 cases
GREEN (20 GNU-gated exit/strict + 2 win help/version), zero r=c:no
rows.
- argument matrix (cmd-matrix.sh sync, one shared cwd): rc 19/19,
stdout 19/19, stderr 19/19 byte-equal old vs new; GNU rc parity 19/19.
- ctest slice 12/12 pass (the -d no-operand, mutual-exclusion and
per-file error wordings are pinned by the suite on top of the
preceding rust2(sync) commit).
Refs #1488
The full ctest sweep after wiring surfaced three rows outside the wired
set: mkfifo/mknod create the kFifoMarker emulation ("!<fifo>" +
FILE_ATTRIBUTE_SYSTEM, native_path.cppm is_winux_fifo_w) and their unit
rows then run `test -p pipe1` (expect 0) and `test -f pipe1` (expect 1).
The pilot's -p returned false unconditionally and -f treated the marker
file as a regular file — the 1.x parser recognized the emulation for
both, and the marker contract is product-wide (mkfifo/mknod/dd/shred
read it).
- "-p" => is_fifo_marker(ctx, arg): SYSTEM attribute + "!<fifo>" head.
- "-f" => false for a marker FIFO.
- Unit test pins the shape end-to-end (SetFileAttributesW for the
attribute, like the C++ suite).
Refs #1488
…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
Local Debug AND Release pass; the CI runner (x64 default leg) alone returns the absolute form for `--relative-to base base\..\base\file.txt`. Two eprintln probes: the relativize common==0 branch prints both sides, and the caller prints when relativize falls back at all. Revert after reading the CI log.
…efix walk (#1488) The CI runner's %TEMP% carries a spelling variant of the subject cwd (8.3 short names / case / junction - the LHS was the canonical LONG spelling while the lexical ctx.cwd-anchored base never matched it), so every --relative-to fell back to absolute on CI only; local Debug and Release both pass. Two eprintln probes confirmed the fallback fires outside the common==0 branch and that the parse state is clean (rel_to/rel_base bound, base_dir Some) - the mismatch is purely in the prefix walk's inputs. Fix at the root: canonicalize the BASE through the same filesystem machinery as the target (AllMustExist, NoCheck fallback for a missing base), so both sides of the common-prefix walk carry identical spellings; the case-insensitive walk stays. Probes reverted. Refs #1488
caomengxuan666
force-pushed
the
rust2/wire-wave1
branch
from
November 10, 2026 18:47
af5e55c to
0998964
Compare
caomengxuan666
added a commit
that referenced
this pull request
Nov 11, 2026
…ve3b) The mechanical replacement deletes the C++ numfmt body, so its 27 catalog keys (command.numfmt.error.*) are no longer produced by the source extraction — the zh-CN catalog now carries them as standing 'extra' drift, exactly like the #1547/#1561 wiring precedents. New diagnostics are emitted by the rust2 library through the bridge and are GNU-shaped, not catalog-keyed. Recorded via check_i18n_drift.py --update-baseline after local confirmation (clone of unixwin/winuxcmd-i18n; growth is numfmt-scoped only). Ref: #1488 (wave3b wiring)
caomengxuan666
added a commit
that referenced
this pull request
Nov 11, 2026
The mechanical replacement deletes the C++ bodies of whoami/nproc/ unlink/sleep/hostname/uname/id/getconf, so their source strings are no longer produced by the extraction: 23 keys disappear from the source catalog (verified by diffing i18n_batch.extract on origin/main vs this branch - all 23 belong to the eight wired bodies, e.g. 'sleep: missing operand', 'unlink: missing operand', 'id: cannot get process identity', 'getconf: no variable specified'; zero keys added). The zh-CN catalog now carries 21 of their legacy.* strings plus command.sleep.error.invalid_interval as standing 'extra' drift, exactly like the #1547/#1561/wave3b wiring precedents; two previously recorded 'missing' drifts (legacy.9b28a3702b3d6726 hostname, legacy.c9d02dd126c4a836 name too long) resolve as a side effect. No new diagnostics are introduced: new-exe messages ride the rust2 bridge and are GNU-shaped. Recorded via check_i18n_drift.py --update-baseline after local confirmation: the same check against the published catalogs is green on origin/main (e466808) and red only on this branch. Ref: #1488 (wave2a wiring)
Merged
caomengxuan666
added a commit
that referenced
this pull request
Nov 11, 2026
Deleting the seven wave2b C++ bodies (base64 base32 b2sum sha224sum sha384sum tac truncate) orphaned their legacy-catalog source strings: 16 new legacy.* extra entries in zh-CN, all introduced by this PR (merge-base b055b48 checks clean). Same deliberate-growth precedent as #1547/#1561 and wave3b's numfmt wiring; the catalogs sync on the next reviewed i18n batch.
Merged
caomengxuan666
added a commit
that referenced
this pull request
Nov 11, 2026
Deleting the seven wave2b C++ bodies (base64 base32 b2sum sha224sum sha384sum tac truncate) orphaned their legacy-catalog source strings: 16 new legacy.* extra entries in zh-CN, all introduced by this PR (merge-base b055b48 checks clean). Same deliberate-growth precedent as #1547/#1561 and wave3b's numfmt wiring; the catalogs sync on the next reviewed i18n batch. # Conflicts: # scripts/i18n-drift-baseline.json
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.
Closes the wiring-wave1 remainder of #1488:
pwd printenv basename dirname readlink realpath mkdir rmdir test [ syncmove to the rust2 staticlib, each C++ body deleted in the same commit (mechanical replacement per rust2/REPLACEMENT-RECIPE.md, no dual track).chmod/chown/dfare deliberately excluded (another branch is deepening their Rust implementations).Prerequisite fix (#1550 leftover)
console:
safePrintRaw/safeErrorPrintRaw— the rust2 bridge drained Rust stdout/stderr throughsafePrint, which applies the legacy i18n catalog lookup (FNV-1a key over the whole payload) to command DATA. The raw writers mirror the translating ones minustranslate_legacy(shared capture handles, console/file detection, byte counting, SIGPIPE mapping); the bridge now drains through them, so basename's result line, printenv's value, pwd's path reach the handle byte-for-byte.Library fixes the gates surfaced (each GNU-probed, own commit)
basename --suf .c /a/f.cprinted "f.c").Case-table changes
test --helpprints nothing; the wired exe prints the WinuxCmd-branded sole-argument help — the product contract the 1.x applet shipped, r=c parity holds); regenerated via gen-cases.py.Verification (three gates per command)
Full-driver
gate/run-gate.sh: no new failures; the only failing rows are getconf/hostname/id/uname (88 rows rc=127 "unknown command") — pre-existing origin/main gap, their registry entries were never merged; out of this wave's scope, flagged for a follow-up.CI note: if the oracle job hits savannah HTTP 500 / runner WSL faults, that is the known infrastructure issue (#1538/#1548 precedent) — not worth retry burn.