bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27986: 26.0.50; 'rename-file' can rename files without confirmation


From: Paul Eggert
Subject: bug#27986: 26.0.50; 'rename-file' can rename files without confirmation
Date: Wed, 16 Aug 2017 16:56:48 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 08/16/2017 03:31 PM, Stefan Monnier wrote:
This should be quite rare.  The only scenario I see matching your
concern is if the source is a directory, the destination is not
a directory name but is an empty directory and is not a symlink, and
the destination is not a descendant of  the source.  Although not
impossible, this will happen so rarely that it doesn't invalidate
the proposed change.
Paul's suggestion makes a lot of sense to me, but I don't quite
understand the above: why does the emptiness of the destination
directory matter?

It's because the system call rename(A,B) always fails when B is a nonempty directory. Hence the proposed (rename-file A B) will fail if B is not a directory name but happens to name a nonempty directory, and therefore rename-file noisily fails instead of silently behaving differently in this case (which was Eli's concern). Conversely, if B is an empty directory then rename(A,B) can succeed (and thereby remove the old B) if all the other conditions are met.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]