coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

Interactive dirs extension to rm

Open janTatesa opened this issue 2 years ago • 5 comments

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

janTatesa avatar Apr 15 '24 08:04 janTatesa

Thanks! Could you replace the screenshots with text?

tertsdiepraam avatar Apr 15 '24 08:04 tertsdiepraam

Thanks! Could you replace the screenshots with text?

Done

janTatesa avatar Apr 15 '24 15:04 janTatesa

If this ever gets implemented, please don't call it --smart-recursive, as it only interacts with the level of iteractiveness, i.e. it lies on a scale: --interactive=always, --interactive=once, <your requested feature>, --interactive=never.

I propose instead: --interactive=dirs

BenWiederhake avatar Apr 20 '24 23:04 BenWiederhake

Okay

janTatesa avatar Apr 21 '24 10:04 janTatesa

Now edited the issue to interactive dirs

janTatesa avatar Apr 21 '24 10:04 janTatesa