Commit Graph

1057 Commits

Author SHA1 Message Date
Sylvestre Ledru efe6dc05f9 find: use GNU wording "unknown predicate" for unrecognized args
GNU find rejects an unrecognized predicate with
"find: unknown predicate '<arg>'", but we printed
"find: Unrecognized flag: '<arg>'". Match GNU so the
tests/find/refuse-noop GNU test (and others hitting the same path)
pass. Add an integration test covering -noop and ---noop.
2026-06-09 22:40:43 +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
Sylvestre Ledru baa6ce5d92 find: fix clippy::unnecessary_semicolon 2026-06-08 22:48:45 +02:00
Sylvestre Ledru 9f33c14fc9 find: fix clippy::map_unwrap_or 2026-06-08 22:48:45 +02:00
Sylvestre Ledru a80620c88f find: fix clippy::redundant_closure_for_method_calls 2026-06-08 22:48:45 +02:00
Sylvestre Ledru a2c75f94ca prepare release 0.9.0 (#714) 2026-06-08 22:44:43 +02:00
dependabot[bot] 44fbc59263 build(deps): bump rstest from 0.25.0 to 0.26.1 (#710)
Bumps [rstest](https://github.com/la10736/rstest) from 0.25.0 to 0.26.1.
- [Release notes](https://github.com/la10736/rstest/releases)
- [Changelog](https://github.com/la10736/rstest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/la10736/rstest/compare/v0.25.0...v0.26.1)

---
updated-dependencies:
- dependency-name: rstest
  dependency-version: 0.26.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-06-08 08:40:05 +02:00
✿ Fleur de Blue fb9f8df047 fix: Handle write failures when printing --help/--version (#656) 2026-06-07 19:05:03 +02:00
Sylvestre Ledru 2044d1e31d make locate and updatedb work on Windows (#704)
locate and updatedb were Unix-only (gated behind cfg and stubbed out on
Windows). Make them cross-platform:

- locate: decode raw DB entries via a platform-specific bytes_to_path
  (verbatim bytes on Unix, lossy UTF-8 elsewhere), use Metadata::len()
  instead of the unix-only size(), and a cross-platform make_symlink in
  tests that skips gracefully when symlink creation is unprivileged.
- drop the #[cfg(unix)] gate on the locate module and the
  "unsupported on Windows" main stubs for locate/updatedb.
- db_tests: remove #[cfg(not(windows))] gates, write updatedb output to
  a tempdir instead of /dev/null, and add a full updatedb->locate
  roundtrip test that is platform-independent.
2026-06-07 11:52:08 +02:00