rm: improve handling of very deep directories with -r
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
In pull request #7304, we added a "quick fix" to support removing very deep directories with rm -r. The corresponding test case in GNU coreutils is in tests/rm/deep-2.sh. It would be better to have a more robust solution.
The issue is that calling path.metadata() on a path that is too long returns an InvalidFilename error. Instead what we should do is use a relative path name and keep setting the working directory as we recurse. It must be possible because std::fs::remove_dir_all(path) seems to work on the very long path.
Originally posted by @jfinkels in https://github.com/uutils/coreutils/pull/7304#discussion_r1958514199
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the rm implementation and the deep-directory test at tests/rm/deep-2.sh, then inspect how recursive removal calls path.metadata(). Rework the deep-path handling as described so the test passes for very deep directories while preserving existing rm -r behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100