Skip to content

winx3-find: fix #1309-#1317 (-ls/-fls/-quit, -size, time predicates, depth range, -user/-group, -perm, -exec, -quit gate, option-like tokens) - #1388

Merged
caomengxuan666 merged 9 commits into
mainfrom
fix/winx3-find
Oct 26, 2026
Merged

caomengxuan666 merged 9 commits into
mainfrom
fix/winx3-find

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Fixes #1309
Fixes #1310
Fixes #1311
Fixes #1312
Fixes #1313
Fixes #1314
Fixes #1315
Fixes #1316
Fixes #1317

winx3-find cluster (REPORT: workspace/winuxcmd-fix/clusters/winx3-find/REPORT.md).

Verification (integration window, 2026-10-26): final-tree mini binary sweep re-run against the PR-head tree: 24/25 cells PASS (sweep script in workspace/merge-sprint/winx-window/find-sweep.sh). The one non-pass cell is -used on the root directory itself: WinuxCmd samples directory times after an enumeration open that bumps atime under Wine (+302 ms measured from a -5.0 ms pre-run gap), while GNU samples before opening; all file sets match, and the cluster's own pristine comparison was identical. Recorded as a follow-up residual (out of this PR's 9-issue scope; invisible on real Windows where NTFS atime updates are off by default) — not a merge blocker.

Discipline check: the 9 commits touch ONLY src/commands/find.cpp + tests/unit/find/find_unit_test.cpp; the 30 unstaged harness-local shim files in the cluster worktree have zero overlap with the commits and were never committed.

i18n: branch extract vs main shows zero key delta (#1313 fragments are string-concatenated, #1315 uses existing fragments) — no catalog action.

Committed gtest file runs in Windows CI (the repo suite executes the installed binary and needs a full product build, which the mingw line cannot provide); behavior is covered locally by the sweep.

…ersal roots (#1317)

GNU rejects every '=value' form (e.g. -maxdepth=1) with 'unknown
predicate', and treats a leading '--' as end-of-option scanning. The
root/expression pre-scan only recognized exact option spellings, so it
swallowed '-maxdepth=1' as a second start point (listing '.' then failing
on the bogus root) and treated '--' itself as a root. Route any dash-led
token that is not a leading global option to the expression parser
(skipping '--' only before the first root; a lone '-' stays a root), and
report unrecognized predicates by name, matching GNU's diagnostic.
…1312)

GNU treats -mindepth 2 -maxdepth 1 as valid and matching nothing (empty
output, exit 0). Only negative depths remain an error.
…ls fields (#1309)

-ls, -fls and -quit are actions, so their presence must suppress the
default -print like -print/-printf/-exec do; previously every -ls line
was followed by a bare-path line and -quit printed the entry. Also
rewrite the -ls/-fls line to GNU's 'ls -dils' shape (inode, 1K blocks,
mode, links, owner, group, size, date, path) with the 6-month date rule
('%b %e %H:%M' vs '%b %e %Y'); fields are single-space separated. The
existing find_quit_stops_after_first_match test pinned the old buggy
output and is updated to GNU behavior (empty stdout; the -print -quit
case keeps covering the traversal-stop property).
)

GNU sizes every type: symlinks by target-path length (lstat), regular
files and directories by stat size, fifos/sockets as 0 units; under -L a
symlink resolves to its target's size, with a dangling link falling back
to the link itself. Replaces the regular-file gate with a follow-aware
size source used by both the expression and the filter evaluation paths.
Directory sizes stay platform-dependent (0 where the platform reports
none); fifo/socket cases are verified under Wine only, as the repo
suite cannot create fifos on Windows.
A u/g/o letter in permission position copies the source class's current
rwx bits (from the mode accumulated so far, starting at 0) into the
target class, for all three operators; '=' still clears the target's
bits first. Previously the class-letter parser admitted only rwxXst and
rejected every copy clause. Tests use only modes the Windows permission
mapping can produce (0755/0644/0555); the 0777-symlink shape is covered
by the same code path and the GNU probe, as Wine does not expose Linux
symlinks as reparse points.
GNU resolves a non-numeric -user/-group name at parse time: an unknown
name is an error (exit 1), not a never-matching predicate. Numeric specs
pass without a lookup, matching the fallback in win32_account_matches.
Diagnostic wording matches GNU verbatim ('... is not the name of a known
user' / '... an existing group'). No committed positive-name test: name
resolution is platform-dependent (e.g. 'root' resolves under Wine but not
on real Windows); the numeric case covers the pass path.
…ive -newermt (#1311)

Replace the floor/trunc age model (which clamped future timestamps to 0
and rejected fractions) with GNU's two window families over the age in
whole seconds: MIN family (amin/cmin/mmin, -used on the atime-ctime gap)
exact (v-1)u <= age < vu, +v age > vu, -v age < vu; DAY family
(atime/ctime/mtime) exact vu <= age < (v+1)u, +v age >= (v+1)u, -v age <
vu. Time numerics now parse as doubles (0.5, .5, 1., 1e3 accepted;
full-consumption check rejects 1e/hex/inf/nan). -daystart uses
calendar-day differences for the DAY family (DST-safe via llround),
preserving the existing -daystart -mtime 0 expectation; the MIN family
now ignores -daystart, matching GNU. -used compares the gap in raw
ticks for the negativity test: a freshly created file can carry atime a
few hundred microseconds before ctime, and GNU (timespec-precise)
treats any negative gap as never-matching. -newermt gains a get_date
subset: now/today/tomorrow/yesterday as now-offsets, last/next unit,
<n>|a unit[s] ago, and month-name dates; 'an' is rejected as GNU
rejects it, as are midnight/noon.
… position (#1315)

run_child no longer overloads 127 for spawn failures: it returns an
optional status with the failure reason (resolve status mapped to
No such file or directory / Permission denied / Not a directory,
CreateProcessW failures via FormatMessage), so the caller can print
GNU's per-file diagnostic (find: '<cmd>': <reason>) while keeping the
exit status unchanged for the \; form (GNU exec.c:388-392) and setting
it for the + form (exec.c:397-399). A child exiting non-zero still
produces no spawn diagnostic. {} is now substituted in the command
position as well as in arguments, and a non-trailing {} in a + form
expands to the full target list (the parser already pops the trailing
{}). Left unhandled and documented: aggregate command-position {} with
+ (one program name cannot be a batch) and -ok prompt display.
…atch (#1316)

GNU evaluates -quit as an action that exits when reached, not when an
entry matched. The scan loops and the root loop gated every quit check
on matched_any, so -quit firing on a non-matching entry let traversal
continue into unvisited roots and report their errors. Remove the
matched_any condition from all quit checks (loop conditions, pre-eval
returns, root-loop break); the post-eval (quit && !matched) and
post-match (quit) returns were already correct and are kept, as are
the matched_any parameter and writes. The regression test uses a
discriminating form (find dir1 missingdir -quit -a -false, GNU rc0),
not the issue's seed form (find emptydir missingdir -name x -quit):
with -name x, -quit is never reached for non-matching entries, so GNU
itself reports the missing root with exit 1.
@caomengxuan666 caomengxuan666 changed the title WIP: fix/winx3-find winx3-find: fix #1309-#1317 (-ls/-fls/-quit, -size, time predicates, depth range, -user/-group, -perm, -exec, -quit gate, option-like tokens) Oct 26, 2026
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 26, 2026 10:01
@caomengxuan666
caomengxuan666 merged commit 84c4ce6 into main Oct 26, 2026
7 of 8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/winx3-find branch October 30, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment