Skip to content

rust2(xargs): GNU findutils 4.9 xargs implementation (#1488) - #1625

Merged
caomengxuan666 merged 5 commits into
mainfrom
rust2/xargs-impl
Nov 14, 2026
Merged

caomengxuan666 merged 5 commits into
mainfrom
rust2/xargs-impl

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Library-form port of GNU findutils 4.9.0 xargs for the rust2 command library (#1488). Rust implementation + gate only; no wiring (src/bridge, src/commands/xargs.cpp, CMakeLists.txt and winuxcmd-ffi are untouched; no childproc.rs changes were needed).

What

  • rust2/crates/winux-cmds/src/xargs.rs: port of xargs.c / buildcmd.c on the shared childproc.rs resolve/build chain (PATH-only execvp shape, PATHEXT, .cmd/.bat via COMSPEC, #! scripts via interpreter).
    • input: read_line / read_string state machines (quotes, backslash, '' items, EOF-string quirks, logical lines with trailing blanks, NUL warning), -0, -d escapes with GNU diagnostics, -a (child keeps stdin; -a - reads stdin; otherwise children get NUL), -E/-e/--eof
    • -I/-i/--replace (bc_do_insert budget, "command too long", leading-blank strip, implies -x), -n/-L/-l with the GNU exclusion warnings
    • -s accounting with GNU's limit messages and clamping, -x, plus the Windows command-line budget (32767 UTF-16 units, 8191 for cmd.exe) that splits batches, with GNU's E2BIG message for a single argument that does not fit
    • -t/-p printing in gnulib shell-escape quoting (checked against probe output), -p/-o through CONIN$ (the /dev/tty analog), -P (WaitForMultipleObjects), --process-slot-var, --show-limits, exact GNU --help/--version
    • exit statuses 0/123/124/125/126/127/1; NTSTATUS-shaped codes map to signals for the 125 message
    • input is read lazily from a 16 KiB buffer and batches run as soon as they are full; io.stdout/io.stderr are flushed before every spawn; with no command given, the library echo runs in-process
  • registry entry (append-only), gate table in gen-cases.py (141 rows, append-only) and cases/xargs.tsv, GATE-REPORT section.

Results

  • cargo test: 723 passed in winux-cmds (21 are xargs tests), whole workspace green; cargo fmt --check clean.
  • bash gate/run-gate.sh xargs: GNU-gated 139 PASS / 0 FAIL, win 2 PASS / 0 FAIL (134 strict / 5 exit / 2 win). C++ parity 115/141. GATE-REPORT.md explains each of the 26 r=c:no rows; in every one the 1.x C++ applet diverges from GNU and Rust matches GNU.

Known gaps (documented in the module doc and GATE-REPORT)

  • No SIGUSR1/2 resizing of -P.
  • --show-limits does not print the "continue now" notice, because that needs isatty(stdin).
  • -p/-o open the console unconditionally, the way GNU opens /dev/tty.
  • When a spawned child writes to a closed pipe on Windows it gets no SIGPIPE, so only the in-process default echo stops with 125.
  • cmd /c children get std's Win32 quoting, not the 1.x caret escaping.
  • Non-UTF-8 input is converted lossily.

DO NOT MERGE until reviewed; wiring will come in a later PR.

caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…ult echo (#1488)

Restricted-fix batch, captain-landed after dual review (lead audit +
verification-lane re-run):

- childproc: quote_windows_arg -> pub(crate)
- echo: echo_bytes(&[&[u8]]) core; OS argv boundary does a single
  lossy conversion; default echo keeps raw bytes (0xff stays 0xff,
  NUL truncation preserved)
- xargs: is_cmd_image (cmd/cmd.exe leaf, case-insensitive, full
  paths) gets literal caret escaping after /c (space tab ^ & | < >
  ( ) "); incremental UTF-16 budget counts escape overhead
- run-gate.sh harness: composite local array assignments split (no
  backslash stripping); GATE_ARTIFACT_DIR/GATE_GNU_REMOTE_ROOT
  parameterized end-to-end; stdout compared via cmp on captured
  files (old shell-variable compare dropped NUL bytes); stderr
  samples copied verbatim; missing side or non-numeric rc = fail.
  No expectation relaxed; new checks can only add failures.

Verification (gate-xargs-reviewed-05, valid rerun; 04 kept as an
environment record): 141 rows (134 strict + 5 exit + 2 win), GNU
139/0, win 2/0, ledger byte-identical to reviewed-03; 9/9 direct
argv/raw-byte probes PASS; cargo test xargs 25/0, echo 15/0.

PR #1625 oracle leg FAILURE adjudicated per the #1538 precedent
(savannah gnulib HTTP 500 at checkout, no test touched); job rerun
green.
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…historical snapshot (#1629)

The checkpoint section records the acceptance state as audited by the
lead review: current main had 50 commands wired (not the historical
76/42 numbers), A1/tail/ABI-v3 are not accepted yet, I18N is an
acceptance prerequisite, and the safety record for preserve-root
(chmod/chgrp/chown) blocks wiring until the listed gates pass.

Captain addendum records same-day movement: #1627 merged, PRs
#1624/#1625/#1626/#1628 open, and the fix/batch-1595-1616-1617 trio.
caomengxuan666 and others added 5 commits November 14, 2026 15:45
Port of findutils 4.9.0 xargs.c/buildcmd.c on the shared childproc
resolver: read_line/read_string state machines (quotes, backslash, EOF
string quirks, logical lines), -0/-d escapes, -I insertion with the
bc_do_insert budget, -n/-L/-I exclusion warnings, -s accounting with the
GNU limit diagnostics plus the Windows command-line budget (32767 UTF-16
units, 8191 for cmd.exe), -t/-p gnulib shell-escape quoting, -p/-o via
CONIN$, -P with WaitForMultipleObjects, --process-slot-var,
--show-limits, and the 0/123/124/125/126/127/1 status contract.
Input streams lazily; the default command runs the library echo
in-process. Unit tests: 21 (scripted tty, broken-pipe streaming).

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
134 strict / 5 exit / 2 win rows; children follow the timeout/nohup
convention (default echo, echo/printf images, sh -c for statuses),
multi-line inputs via -a setup files. GNU-gated 139/139, win 2/2.

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…1488)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ult echo (#1488)

Restricted-fix batch, captain-landed after dual review (lead audit +
verification-lane re-run):

- childproc: quote_windows_arg -> pub(crate)
- echo: echo_bytes(&[&[u8]]) core; OS argv boundary does a single
  lossy conversion; default echo keeps raw bytes (0xff stays 0xff,
  NUL truncation preserved)
- xargs: is_cmd_image (cmd/cmd.exe leaf, case-insensitive, full
  paths) gets literal caret escaping after /c (space tab ^ & | < >
  ( ) "); incremental UTF-16 budget counts escape overhead
- run-gate.sh harness: composite local array assignments split (no
  backslash stripping); GATE_ARTIFACT_DIR/GATE_GNU_REMOTE_ROOT
  parameterized end-to-end; stdout compared via cmp on captured
  files (old shell-variable compare dropped NUL bytes); stderr
  samples copied verbatim; missing side or non-numeric rc = fail.
  No expectation relaxed; new checks can only add failures.

Verification (gate-xargs-reviewed-05, valid rerun; 04 kept as an
environment record): 141 rows (134 strict + 5 exit + 2 win), GNU
139/0, win 2/0, ledger byte-identical to reviewed-03; 9/9 direct
argv/raw-byte probes PASS; cargo test xargs 25/0, echo 15/0.

PR #1625 oracle leg FAILURE adjudicated per the #1538 precedent
(savannah gnulib HTTP 500 at checkout, no test touched); job rerun
green.
@caomengxuan666
caomengxuan666 merged commit 46439c0 into main Nov 14, 2026
15 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…trip preflight (#1721)

The rust2-gate CI job ran the whole GNU side into MISSING (81/81,
pass=0 fail=81) while wsl.exe itself "succeeded": Git Bash (MSYS2)
rewrites leading-slash argv before spawning a native binary, so the
harness's "wsl.exe --exec /bin/bash /mnt/<drive>/..." reached the
distro as execvpe(D:/Git/usr/bin/bash) -> No such file or directory,
with stderr swallowed. Byte-level repro on the local Git Bash; with
MSYS_NO_PATHCONV=1 the same invocation runs the probe verbatim and
/mnt automount is fine.

Two semantic conflicts met here: #1625 moved the GNU leg onto this
call shape (its local verification ran under the niubash family,
which never converted this shape), and #1632 put the harness under
Git Bash on CI. Export MSYS_NO_PATHCONV=1 inside the harness so
every caller is safe, and add a one-roundtrip preflight that fails
in seconds instead of MISSING-ing the corpus for minutes.

Verified in the exact failing shell (Git Bash, this repo's gate
subset): GNU-gated 81 PASS / 0 FAIL, win 12 / 0 - matching the
pre-#1625 attested numbers.
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