Repository navigation
WIP: 模拟层 builtins 选项纪律九单(#1941-#1948 + #1939) - #2018
Merged
Merged
Conversation
…ons, =value (rubash#1941, #1942, #1946) Shared gnulib-style machinery in external_file_builtins.rs: resolve_long_option (exact match / unique-prefix abbreviation / no_abbrev), grouped argmatch for option values, and the coreutils 9.4 diagnostic shapes with the Try line. cp is the first consumer: - #1941: --preserve validates against the full attribute table (mode/timestamps/ownership/links/context/xattr/all) with argmatch prefixes; invalid or empty elements diagnose with the Valid arguments block and create nothing; links reuses the first copy through an inode identity map (hard_link); xattr is copied best-effort on unix. - #1942: unknown long options report the whole word (=value included), ambiguous prefixes list candidates in table order, unambiguous abbreviations are accepted, unknown short options gain the Try line; dead cp_usage_text removed. - #1946 (cp leg): a no-argument long option given =value fails with the canonical-name "doesn't allow an argument" diagnostic. Regression pins: the #1941/#1942 sections of tests/issue1941_1948_sim_layer_option_regressions.rs.
…te machine (rubash#1944, #1947, #1948, #1946) - #1944: -f is GNU's silent legacy no-op flag, not an invalid option. - #1947: missing values for -r/-t/-d and --date/--reference/--time diagnose in the short/long coreutils forms with the Try line; --time resolves through grouped argmatch with its Valid block. - #1948: -t converts eagerly (a bad stamp fails at once, a later valid -t cannot rescue it); -d/-r are recorded during the scan and resolved once after it — last wins, superseded references are never stat'ed and superseded dates never parsed; -t with -d/-r is the more-than-one-source error; -r with -d stats the reference first, then parses the date, and the date wins in either order. touch_declines resolves abbreviations through the same table. - #1946 (touch leg): no-argument long options reject =value by canonical name through the shared resolver. Regression pins: the #1944/#1947/#1948 sections of tests/issue1941_1948_sim_layer_option_regressions.rs.
- #1946 (rm leg): --force=x / --recursive=x / --dir=x / --verbose=x fail with the canonical "doesn't allow an argument" diagnostic; unknown options keep the whole-word unrecognized form; --ver reports the verbose/version ambiguity. - --no-preserve-root may not be abbreviated: any proper prefix fails with "rm: you may not abbreviate the --no-preserve-root option" (no Try line, coreutils 9.4). --preserve-root keeps its optional argument and its own value diagnostic. rm_declines resolves abbreviations through the same table, so abbreviated --interactive forms decline like the full spellings. Regression pins: the #1946 section of tests/issue1941_1948_sim_layer_option_regressions.rs.
…dows arm (rubash#1945) The Windows leaf no longer exits 0 in silence: an invocation with no operand prints "mkfifo: missing operand" plus the Try line (rc 1); a dangling -m or --mode prints the short/long requires-an-argument forms; unknown short and long options diagnose instead of being swallowed; -m consumes the rest of its cluster or the next word. Per-operand refusals are unchanged, and the non-Windows face still declines wholesale (rubash#1725). Regression pins: the #1945 section of tests/issue1941_1948_sim_layer_option_regressions.rs (Windows-gated — the shape only exists on the Windows arm).
…h#1943) coreutils mode_adjust judges X against the mode the file had before this invocation, plus is_dir — never against bits an earlier clause of the same mode string just created (a 644 file under `u+x,g+X` ends 744, not 754). apply_chmod_mode takes is_dir and tests the ORIGINAL base; the call site reads is_dir from the same metadata that supplies the base mode. Regression pins: the #1943 section of tests/issue1941_1948_sim_layer_option_regressions.rs.
GNU print_formatted_time (execute_cmd.c:1346) expands only % directives; every other byte, backslash included, is copied verbatim, so TIMEFORMAT='A\nB' prints a literal backslash-n. expand_time_format drops its backslash-decoding arm, and the default format becomes BASH_TIMEFORMAT's actual value — real newline and tab characters (execute_cmd.c:1245) — instead of backslash escapes the old expander happened to decode. Regression pins: tests/cli_tests.rs timeformat_backslash_is_a_literal_byte and time_default_format_starts_with_a_real_newline_and_tabs.
…ash#1941) CI round 1 on PR #2018 caught two target breaks in the cp commit: - Windows: MetadataExt::file_index is the unstable windows_by_handle feature (E0658). cp_inode_key now takes the source path and, on Windows, reuses executor::path::file_identity (promoted to pub(crate)) — the stable handle-based (volume serial, file index) pair `[ a -ef b ]` already compares. - macOS: libc's listxattr/getxattr/setxattr take extra options/position arguments (E0061). The copy walk now goes through xattr_list/xattr_get/xattr_set shims that fold those to zero on macOS and forward the Linux/Android forms elsewhere. Verified locally: cargo check --lib clean on x86_64-linux and x86_64-pc-windows-gnu; the darwin leg is CI-verified (this host lacks the psm cross C toolchain).
caomengxuan666
marked this pull request as ready for review
October 29, 2026 01:38
caomengxuan666
added a commit
that referenced
this pull request
Oct 29, 2026
New battery tests/issue2036_s4_projection_regressions.rs pinning the projected faces' current behavior, measured on the post-projection tree: - stage arms (grep/head/wc/tr/sed/trap -p), true/false status, the pre-check's 127 decline, the sequential-route cat arm replacing while the planner yields (the registered per-face rule), the yes stand-in; - timed models: consumer timeout 142, producer+consumer+followup chain, bare-read model engagement; - comsub word arms (echo/printf/cat + its stand-down decline-to-127, basename/umask/pwd/type/kill/ulimit), the mktemp arm answering for an unresolvable name (its registered per-face rule), the exact-body True/Colon/False slots; - comsub timed arms (echo/cat/tty + the time report), the front face's tty bare and slash forms, heredoc cat and sort -u; - the #2066 host-flag gates riding the projected slots (Session Tier-C seam, #2066 probe technique): cat off -> PATH program, on -> in-process; sed off -> PATH program, on -> still the PATH program via the arm's InvertedSed recheck. Two adjudications recorded in the battery itself: the sed flag-on expectation follows the InvertedSed row (it is not a plain Replace), and a bare trap-table print is deliberately not pinned (it reflects signal dispositions inherited from the host process, which this binary's own Session tests mutate - a pre-existing host-visible side effect, orthogonal to S4). Local gates: battery 17/17 (twice), lib suite 961/1/3 with the failure set identical to the master baseline (the +2 passes are the new registry pins), -D warnings clean on the lib and this slice's test targets (the one all-targets -D warnings failure is the pre-existing dead_code in the #2018 test file, owned by PR #2079). Refs #2036
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.
WIP: 模拟层 builtins 选项纪律九单(cp/chmod/touch/mkfifo/rm + TIMEFORMAT)
共享机制一处收敛:
external_file_builtins.rs新增 gnulib getopt_long纪律层——
resolve_long_option(精确/唯一前缀缩写/no_abbrev)、groupedargmatch值匹配、coreutils 9.4 逐字节诊断助手(含 Try 行);各命令选项表驱动 handler 与 declines,不再逐命令手写 match。
Fixes #1941
Fixes #1942
Fixes #1943
Fixes #1944
Fixes #1945
Fixes #1946
Fixes #1947
Fixes #1948
Fixes #1939
逐单要点(oracle = 本机 coreutils 9.4 + GNU bash 5.3.20 实测):
xattr/all)+ argmatch 前缀 + 非法/空元素诊断(Valid arguments 块),
links 经 inode 身份映射在目标侧 hard_link 复用;xattr unix 尽力拷贝。
Try 行;删死代码 cp_usage_text。
多子句不被先行子句污染)。
缺值诊断、未知选项诊断(均 +Try、rc1)。
allow an argument(缩写拼写亦报规范名)。
grouped argmatch + Valid 块。
胜;-d/-r 延迟、末值胜、被取代者永不 stat/parse;多源冲突判决序与
-r/-d 并存时「先 stat 后 parse、日期值胜」均按实测。
默认格式改 BASH_TIMEFORMAT 的真实控制字符值(:1245)。
回归钉:tests/issue1941_1948_sim_layer_option_regressions.rs(逐单种子)