Skip to content

fix(ln): -i/-f follow last-wins order (Refs #1651) - #1662

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/1651-ln-if-last-wins
Nov 14, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/1651-ln-if-last-wins

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

fix(ln): -i/-f follow last-wins order (Refs #1651)

Summary

GNU ln processes -i/-f in argv order, last wins (ln.c:505-512: -f sets remove_existing_files and clears interactive; -i clears remove_existing_files and sets interactive). The port set each flag independently and checked interactive first, so -i always won: ln -i -f a b prompted and refused on 'n' (rc 1) where GNU forces (rc 0).

Fix mirrors the GNU flag pair in both the long-option and short-option parsers of rust2/crates/winux-cmds/src/ln.rs. Short clusters already walk char by char in order, so -if forces and -fi prompts with no extra code. remove_existing() is untouched: with GNU-mirrored flags its prompt-first/force/Refused branches already implement the order.

GNU semantics

coreutils 9.4 src/ln.c:488 (both flags default false), :505-512 (the pair), :213 (force = remove_existing_files || interactive || backup), :275 (prompt iff interactive, decline on no).

Verification

  • Oracle (system ln = GNU coreutils 9.4): 8 shapes, all match — -i -f / -f -i x {n, y}, -if / -fi clusters, --interactive --force / --force --interactive.
  • Regression nail: in-crate test interactive_force_last_wins, 8 cells mirroring the oracle table.
  • git diff --check + rustfmt clean.
  • Local execution NOT possible on Linux: winux-cmds does not compile on Linux at all (pre-existing Windows-only APIs in untouched modules: windows::os, raw_arg, creation_flags, as_raw_handle, file_attributes). The new test + whole ln module must run on Windows CI / X299.
  • No new user-visible text → no i18n catalog change.

What this PR deletes

None. No code paths removed; only the -i/-f flag-assignment semantics changed.

Refs #1651

GNU ln.c:505-512 assigns both flags on each option (-f sets remove_existing_files and clears interactive; -i clears remove_existing_files and sets interactive), so the last of the pair governs. The port set each flag independently and checked interactive first, so -i always won. Mirror the GNU pair in the long and short parsers; clusters already walk in order (-if forces, -fi prompts).

Regression nail: interactive_force_last_wins (8 cells, oracle shapes).
@caomengxuan666

Copy link
Copy Markdown
Member Author

Captain review: PASS

Reviewer: read-only review (dossier ~/workspace/review-1662/CAPTAIN-VERIFY.md, currently staged at /tmp/review-1662-CAPTAIN-VERIFY.md pending the local write wall; to be moved when the wall opens). No reviewer post/merge — this comment is the captain's verdict.

Mechanism — PASS. GNU coreutils 9.4 ln.c re-read: :488 defaults, :505–508 -f, :510–512 -i, :213 force formula, :275 prompt-iff-interactive. The diff is exactly 3 hunks (long parser, short parser, test); remove_existing() untouched and its branches implement GNU order once the flags mirror GNU. Flags assigned at exactly 4 sites, consumed only at ln.rs:492/498.

Pins — PASS. Oracle re-run by the reviewer: all 8 cells match (rc / b-content / prompt). CI job log (not just the green check), job 132393993745: test ln::tests::interactive_force_last_wins ... ok, all 9 ln tests ok, suite 753 passed / 0 failed.

CI — one red job, dispositioned by the captain (F1, waived). Run 43577222551: 7 pass (build-windows ×4, rust-tests, rust2-surface-check, i18n-drift), 4 skipping, rust2-gate FAILURE (job 132399945606: GNU-gated cases: pass=0 fail=81, all 81 g_rc=MISSING — the WSL GNU side produced zero output files). Run 43577222561 (GNU master differential): all pass. Waiver evidence: the identical failure occurs on main with no PR involved — run 43576809702 on main head 8be156e, job 132401917691, same step, same 81× g_rc=MISSING, same summary. The gate tests csplit/pathchk/ptx (never ln) and the PR touches only ln.rs. This is a standing CI-infra break, not a product signal; tracked as #1692. No required status checks are set on the branch.

Fail-first — owed, not blocking (F2). Not banked: X299 has no direct GitHub route and the server-side clone crawled (~3–35 KB/s); box disk is full. The reviewer's X299 attempt produced only a VOID PowerShell command-not-found (no driver was ever built). Accepted as non-blocking: the oracle table is 8/8, the nail is proven to have run green on head, and the base behavior is the reported bug itself (issue repro). Bank opportunistically later from the server leftovers (~/review-1662-src, stage scripts).

Hygiene — PASS. git diff --check clean; rustfmt --edition 2021 --check clean; deletion section present and true ("None"); closing scan: only Refs #1651, no close keywords. No new user-visible text; i18n-drift passed. 59 lib + 88 lib-test warnings in the rust-tests log, zero in ln.rs — pre-existing.

Intersection — ∅, merge without update-branch. Merge-base 35f4864; live tip 7a0873c (PR #1664, childproc shebang, merged 17:48). Interval files: DOCS/2.0-MASTER-PLAN.md, rust2/crates/winux-cmds/src/childproc.rs, rust2/crates/winux-cmds/src/xargs.rs, src/utils/childproc.cppm, tests/unit/childproc/childproc_unit_test.cpp — ln.rs absent. Zero-intersection exception applies (precedent #3141/#3576/#3526).

Merge notes. #1651 stays open mechanically (Refs only); the fix fully resolves the reported case, so the captain will close #1651 manually after merge. Adjacent -b × -i divergence already filed as #1675.

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 14, 2026 09:55
@caomengxuan666
caomengxuan666 merged commit 1275ccf into main Nov 14, 2026
15 of 16 checks passed
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