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

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

Re: Dangerous behavior when copying to current directory


From: David Kastrup
Subject: Re: Dangerous behavior when copying to current directory
Date: Thu, 10 Mar 2005 12:01:58 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Richard Stallman <address@hidden> writes:

> It is not very dangerous, since it asks the user for confirmation.

I just have been bitten by something even worse: namely rename-file.
I wanted to move a file into some other directory.  So I did
M-x rename-file RET somefilename RET /tmp RET

then I got the question

"/tmp/ already exists.  Continue?"

Well, weird question, but I replied "yes" to it, figuring that it
would not recursively remove the directory and the worst that could
happen would be that this fails.

What happened is that Emacs took the name of the current buffer and
overwrote the file with that name in /tmp.  I did not notice this
until it told me the file on disk had changed and would I want to
revert.  Thinking it was CVS-related, I did.

Undo did not work, no backup yet.

I recovered the file contents from a mail where I had sent out the
latest version to a customer.

> But it may be inconvenient and annoying.

It is more than that.  Overwriting an unrelated file, and in the case
of rename-file even completely without announcing the file that is
going to suffer the damage, is intolerable.

Even if there is a question "file exists" when the target is a
directory.

> I agree it would be better to change this.  It is not easy to do,
> since there is no way for a C primitive to use Lisp code to read the
> arguments.

Then it should just refuse to do anything instead of writing over what
amounts to an arbitrary unrelated file.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum




reply via email to

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