Commit Graph

1064 Commits

Author SHA1 Message Date
Jesse Rosenstock 795d29ab35 xargs: clarify -x and -t help text
The previous text implied -x only interacts with -L/-n and used
imprecise phrasing. The new text mirrors the POSIX spec: terminate
when a constructed command line would exceed the size limit rather
than reducing the argument count.

Clarify that -t prints each command to stderr, rather than just
"be verbose".
2026-06-10 15:00:22 +02:00
xtqqczze c619fbeb82 chore(deps): update rust crates 2026-06-10 14:51:52 +02:00
weili a70f5ccd7c find: -ls: don't panic on an unmapped owner uid/gid
`find <file> -ls` panicked (exit 101) when the file's owning uid (or gid) had
no `/etc/passwd` (`/etc/group`) entry: it resolved the name with
`User::from_uid(...).unwrap().unwrap()`, and the inner unwrap aborts on the
`Ok(None)` that an unmapped id returns. Unmapped owners are routine (extracted
archives, NFS, deleted accounts, container images).

Resolve the uid/gid via `uucore::entries::uid2usr`/`gid2grp`, falling back to
the numeric id when there is no entry, matching GNU find (which prints the
number). These helpers already serialize the non-thread-safe getpwuid/getgrgid
behind a mutex, so reuse them rather than reimplementing the lookup.

Add a -ls integration test that chowns a file to an unmapped id and checks the
numeric fallback; it skips when the process lacks the privilege to do so.
2026-06-10 07:45:53 +02:00
weili 5992901805 find: -printf: test octal escape before a multibyte char
Regression test for the panic fixed in #720/#723: a `\NNN` octal escape
immediately followed by a multibyte character (`\0€`) used to slice the
format string mid-char and abort. Assert `-printf` emits the escape byte
and the following character intact.
2026-06-10 07:45:25 +02:00
Sylvestre Ledru 782744f35c ci: build and lint the wasm32-wasip1 target
Add a job that installs the wasm32-wasip1 target plus the WASI SDK (so the
bundled C in onig_sys can be cross-compiled) and runs cargo build and
clippy -D warnings, so non-Unix compilation can't regress.
2026-06-10 07:45:04 +02:00
Sylvestre Ledru c100ac226f build: support compiling for non-Unix targets such as wasm
The platform-specific code was split into cfg(unix)/cfg(windows) arms, so
wasm32 targets (which are neither) failed to compile. Widen the generic
Windows stubs to cfg(not(unix)) and make the -ls printer and xargs size
limiters fall back to portable APIs when no platform-specific one exists.
2026-06-10 07:45:04 +02:00
dependabot[bot] 5bf236b891 build(deps): bump regex from 1.12.3 to 1.12.4
Bumps [regex](https://github.com/rust-lang/regex) from 1.12.3 to 1.12.4.
- [Release notes](https://github.com/rust-lang/regex/releases)
- [Changelog](https://github.com/rust-lang/regex/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rust-lang/regex/compare/1.12.3...1.12.4)

---
updated-dependencies:
- dependency-name: regex
  dependency-version: 1.12.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-10 07:15:21 +02:00
weili 001966f326 find: -name: don't panic on a malformed POSIX bracket class
A `-name` glob with a `[.`/`[=`/`[:` introducer whose closing delimiter is
missing — only a lone `]` (or the delimiter) before a multibyte char, e.g.
`'[[:]é'` — panicked (exit 101). `extract_bracket_expr` searched for *either*
the delimiter or `]` and then added a blind `+ 2`, which overshot into the
following character and sliced off a UTF-8 boundary.

Search for the actual two-byte closing sequence `<delim>]` instead. A valid
class (`[:alpha:]`) is unchanged; a malformed one returns None, so the caller
treats `[` literally and accepts the pattern like GNU find (exit 0). Reachable
via -name/-iname/-path/-ipath/-lname/-ilname. Adds a regression test.
2026-06-09 22:41:13 +02:00
weili 53980035af find: -printf: don't panic on a multibyte char after an octal escape
`\NNN` octal escapes were parsed by slicing a fixed 3 bytes off the
format string, which panics when fewer than 3 octal digits are followed
by a multibyte character (e.g. `-printf '\0€'`): the 3-byte slice lands
inside the multibyte char and trips a char-boundary assertion.

Parse the octal escape from the leading octal digits only (1 to 3, all
ASCII) and advance by their byte length. This also fixes `\1`..`\7`,
which previously fell through to the single-character escape table and
errored instead of being treated as octal, matching GNU find.
2026-06-09 22:23:39 +02:00
weili e2d84e98d5 locate: don't panic on a too-short --database file
`locate -d <file> <pattern>` panicked (slice index underflow, exit 101) when
the database file is exactly one byte: `check_db` consumes that byte with
`read_exact`, then `read_until(b'\0', ...)` hits EOF and appends nothing,
leaving `buf` empty. `&buf[..buf.len() - 1]` then underflows `buf.len() - 1`
to `usize::MAX` and slices out of bounds.

Strip the trailing nul with `strip_suffix(b"\0")` (falling back to the whole
buffer when `read_until` stopped at EOF without one) instead of slicing
`buf.len() - 1`. An empty buffer now yields `None` (unrecognized format), so
the too-short database is skipped like any other invalid one and locate exits
1 instead of crashing. Adds a regression test.
2026-06-09 22:23:23 +02:00
dependabot[bot] 865ab0991e build(deps): bump moonrepo/setup-rust from 0 to 1
Bumps [moonrepo/setup-rust](https://github.com/moonrepo/setup-rust) from 0 to 1.
- [Release notes](https://github.com/moonrepo/setup-rust/releases)
- [Changelog](https://github.com/moonrepo/setup-rust/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moonrepo/setup-rust/compare/v0...v1)

---
updated-dependencies:
- dependency-name: moonrepo/setup-rust
  dependency-version: '1'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 09:35:56 +02:00
dependabot[bot] 8add685cc6 build(deps): bump codecov/codecov-action from 6 to 7
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 6 to 7.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/v6...v7)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 09:29:29 +02:00
dependabot[bot] c4afeab1bc build(deps): bump actions/checkout from 4 to 6
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-06-09 09:29:07 +02:00
Sylvestre Ledru 62deaf6e60 updatedb: clear error when the output database can't be created
Opening the output file with `?` surfaced a bare "No such file or
directory" with no indication of which file failed (easy to hit because the
default output path /usr/local/var/locatedb often doesn't exist).

Report it like GNU does, naming the path and the reason, e.g.
`cannot create '/usr/local/var/locatedb': No such file or directory`.
strip_errno() drops the trailing "(os error N)" noise.
0.9.0
2026-06-08 23:38:59 +02:00
Sylvestre Ledru 1be5541c74 find: avoid redundant stat per -fstype evaluation
The -fstype matcher called path.symlink_metadata() (a statx/lstat syscall)
on every entry before consulting its cache, just to obtain the device id.
With several -fstype clauses on the same expression (as updatedb builds:
nfs/NFS/proc), every file was stat'd once per clause.

Derive the device id from WalkEntry::metadata() instead, which is cached on
the entry in a OnceCell and shared across all matchers, so each file is
stat'd at most once regardless of how many -fstype clauses run.

On 'updatedb --localpaths=/usr' (~506k files) this drops statx calls from
~1.52M to ~506k and wall-clock from ~1.82s to ~1.32s, with byte-identical
output.
2026-06-08 23:38:59 +02:00
Sylvestre Ledru 5d0e7add34 lints: enable clippy all/cargo/pedantic groups, mirroring uutils/coreutils
Enable the broader clippy lint set used by uutils/coreutils (the all,
cargo and pedantic groups plus the use_self nursery lint), allowing the
noisy/low-value lints. The preceding commits fix the warnings these
groups surface so the tree stays warning-free.
2026-06-08 22:48:45 +02:00
Sylvestre Ledru 42f8a9af36 find: fix clippy::needless_for_each 2026-06-08 22:48:45 +02:00
Sylvestre Ledru 664a9c23e6 xargs: fix clippy::needless_continue 2026-06-08 22:48:45 +02:00
Sylvestre Ledru fd4bd6acfa find,xargs: fix clippy::items_after_statements 2026-06-08 22:48:45 +02:00
Sylvestre Ledru fa4f90befb find: fix clippy::unnecessary_wraps 2026-06-08 22:48:45 +02:00
Sylvestre Ledru 7deeee6fdf find: fix clippy::unreadable_literal 2026-06-08 22:48:45 +02:00
Sylvestre Ledru 51a50022c2 find: fix clippy::assigning_clones 2026-06-08 22:48:45 +02:00
Sylvestre Ledru 600f3af140 find: fix clippy::implicit_clone 2026-06-08 22:48:45 +02:00
Sylvestre Ledru a63482b8cf find: fix clippy::match_bool 2026-06-08 22:48:45 +02:00
Sylvestre Ledru 47796303ca find: fix clippy::single_match_else 2026-06-08 22:48:45 +02:00