uutils / uutils/coreutils

Interactive dirs extension to rm

Open
#6,237 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - rm
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

I want to not have to type rm -r when I remove a directory, and also I want it secure so I've aliased rm to coreutils rm -rI. The problem is that I get prompted even when removing files. This behavior is present in GNU as well. So I suggest adding a --interactive=dirs option. It will prompt only when at least one of the arguments is a directory.

Behaviour of rm -rI

user@machine> rm -rI foo
rm: remove 1 argument recursively?

It removes recursively no matter whether the argument is a file or directory

Requested behavior of rm -r --interactive=dirs

user@machine> rm -r --interactive=dirs foo
user@machine>

When no arguments are directories it doesn't remove recursively

user@machine> rm -r --interactive=dirs foo bar/
rm: remove 2 arguments recursively?

When at least one argument is a directory it produces the same behavior as rm -rI

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files or tests. Start by tracing the rm command's handling of -r, -I, and interactive options, then compare its behavior with the shell examples for file and directory arguments. Done means --interactive=dirs prompts only when at least one argument is a directory and matches the requested recursive behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.