Description
When --full-path (or -f) is used, fd builds absolute paths for each match. If the process’s current working directory becomes invalid during the search (e.g. it was deleted or permissions changed), the program can panic instead of reporting an error.
Location: src/walk.rs, in the worker closure that builds search_str for full-path matching (around lines 521–524).
Cause: filesystem::path_absolute_form(entry_path) can return an Err (for example when env::current_dir() fails). The code uses .expect("Retrieving absolute path succeeds"), which turns that error into a panic.
Reproduction (conceptually):
- Start fd with
--full-path in a directory.
- From another process/shell, remove or make the current directory inaccessible (e.g.
rmdir the CWD or revoke access) while the search is running.
- When fd tries to resolve a relative path,
path_absolute_form fails and the process panics.
Suggested fix: Do not use .expect(). Either propagate the error (e.g. with ?) so the search can fail gracefully, or send a WorkerResult::Error and continue, so the user gets an error message and a non-zero exit code instead of a panic.
Description
When
--full-path(or-f) is used, fd builds absolute paths for each match. If the process’s current working directory becomes invalid during the search (e.g. it was deleted or permissions changed), the program can panic instead of reporting an error.Location:
src/walk.rs, in the worker closure that buildssearch_strfor full-path matching (around lines 521–524).Cause:
filesystem::path_absolute_form(entry_path)can return anErr(for example whenenv::current_dir()fails). The code uses.expect("Retrieving absolute path succeeds"), which turns that error into a panic.Reproduction (conceptually):
--full-pathin a directory.rmdirthe CWD or revoke access) while the search is running.path_absolute_formfails and the process panics.Suggested fix: Do not use
.expect(). Either propagate the error (e.g. with?) so the search can fail gracefully, or send aWorkerResult::Errorand continue, so the user gets an error message and a non-zero exit code instead of a panic.