On 03/09/15 15:56, Alex Henrie wrote: > Hi, > > I have run into an annoying problem with GNU rm. When I try to remove > a file to which I do not have write permission from a directory to > which I do not have write permission, rm warns me about the file being > read-only before telling me that I do not actually have permission to > delete it: > > $ sudo mkdir foo > $ sudo touch foo/bar > $ rm foo/bar > rm: remove write-protected regular empty file 'foo/bar'? yes > rm: cannot remove 'foo/bar': Permission denied > > It looks like rm could use dirname and faccessat to check for write > permission on the parent directory before showing a prompt. Would you > be willing to add a preliminary check like this to rm to avoid useless > prompts? To clarify, what I want to see is: > > $ sudo mkdir foo > $ sudo touch foo/bar > $ rm foo/bar > rm: cannot remove 'foo/bar': Permission denied > > Of course, if I have write permission to the directory but not the > file, I would still expect to see a warning about deleting a read-only > file (unless -f is given). > > Please let me know if this is a feasible change.
I see your point. It's similar to the prompting discussed in http://bugs.gnu.org/16669 The most general behavior is the current one, where the operations are independent, allowing in this example for the dir to be `chmod +w` while the prompt is displayed. Now that would be unusual. I need to think more about it. thanks, Pádraig.
