[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
rm issue (round 2)
From: |
Ken Nellis |
Subject: |
rm issue (round 2) |
Date: |
Mon, 05 Dec 2005 16:56:19 -0500 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.2) Gecko/20040804 Netscape/7.2 (ax) |
Paul Eggert wrote:
Could you please forward that suggestion to address@hidden Thanks.
(Better yet would be a patch, but I realize not everyone can do that....)
Dear bug-coreutils:
(This is a follow-up to a original mail of 12/2/05. Recapping the
exchange so far, the original mail suggested a change in rm's default
behavior when attempting to delete a file that doesn't exist. Several
replies indicated that this violated POSIX and offered unsatisfactory
workarounds, however to Paul Eggert I suggested a change that might not
violate POSIX. This is my response to his request that I forward my
latest suggestion back to bug-coreutils.)
There is a behavior in rm that prompts me to write to request a
modification. Consider a user who doesn't like to type out long file
names and wants to delete one of many files in a directory, so he asks
rm to prompt him for the one to delete:
rm -i *
However, he accidentally misses the hyphen and instead types:
rm i *
The unfortunate behavior of rm in this case is to tell our hapless user
that file "i" doesn't exist and then proceed to delete all the files in
the directory.
A safer behavior for rm would be to stop deleting files when it
encounters one that doesn't exist. In my example, after diagnosing that
file "i" doesn't exist, rm would not proceed to wipe out the directory.
To implement this behavior while remaining POSIX compliant, I suggest
adding a new option to rm, e.g., --stop-on-file-not-found. This could be
aliased (alias rm='rm --stop-on-file-not-found') and allow our hapless,
hypothetical user to avert disaster.
Pseudo rm code:
foreach file
if (file doesn't exist)
complain
if (stop-on-file-not-found)
break
else
continue
end if
end if
delete file
end foreach
Sincerely,
Ken Nellis
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- rm issue (round 2),
Ken Nellis <=