[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Feature Request: Removal of '-f' Short Option in 'rm' Command
From: |
Bernhard Voelker |
Subject: |
Re: Feature Request: Removal of '-f' Short Option in 'rm' Command |
Date: |
Mon, 25 Sep 2023 20:05:24 +0200 |
User-agent: |
Mozilla Thunderbird |
On 9/25/23 08:12, Owen Chia wrote:
Dear GNU Coreutils Team,
I hope this email finds you well. I am writing to propose a feature request
regarding the 'rm' command in GNU Coreutils. Specifically, I would like to
suggest the removal of the '-f' short option, while retaining the '--force'
long option.
The rationale behind this proposal stems from the observation that the '-f'
short option has led to numerous accidental deletions due to its ease of use
and associated muscle memory. By removing the short option and encouraging the
use of the longer '--force' option, we can mitigate such unintended
consequences and promote safer usage of the 'rm' command.
Besides - what Arsen mentioned already - that POSIX requires -f, I think
there's a
misunderstanding about how -f works.
From `rm --help`:
-f, --force ignore nonexistent files and arguments, never prompt
What ignoring nonexistent files means is clear, but when would rm(1) prompt?
E.g. it does not prompt when deletion easily works.
The following delete a 4-level directory hierarchy with 40 directories
and 81 files:
$ mkdir -p testdir/a{1..3}/b{1..3}/c{1..3}
$ touch testdir/a{1..3}/b{1..3}/c{1..3}/file{1..3}
$ rm -r testdir -v 2>&1 | wc -l
121
But rm(1) would prompt if e.g. a file in the tree is read-only.
Furthermore, even if we removed the -f option (and thus violate POSIX),
the request is not feasible. Millions of scripts are using -f.
Should uses of `rm -f` fail with "invalid option" and render all those
scripts invalid? No.
Or should it silently be ignored ... but all the script rely on '-f' e.g. for
nonexistent files? No.
It is nearly impossible to change such well-known and often used options which
exist since almost half a century.
Have a nice day,
Berny