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

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

bug#38707: dired-do-rename doesn't check for "/" !


From: Nick Helm
Subject: bug#38707: dired-do-rename doesn't check for "/" !
Date: Tue, 24 Dec 2019 17:28:55 +1300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin)

Dan Jacobson <jidanni@jidanni.org> writes:

> Let's say you tell it to rename qqq to "xxx/yyy/zzz/".
>
> And it works.
>
> You get xxx/yyy/zzz/qqq
>
> But if there is no directory zzz,
> then one day you will discover you got
>
> xxx/yyy/qqq .

I'm not sure this is actually a bug, but it looks like the behaviour
happens because of these lines in dired-do-create-files.

;; rename-file bombs when moving directories unless we do this:
(or into-dir (setq target (directory-file-name target)))

Dired could check for and issue an error in the case where the source is
a file and the target appears to be a non-existent directory. Something
like this perhaps?

--- a/lisp/dired-aux.el 2019-12-23 15:12:26.000000000 +1300
+++ b/lisp/dired-aux.el 2019-12-23 15:18:17.000000000 +1300
@@ -1878,6 +1878,10 @@
        (apply (car into-dir) operation rfn-list fn-list target (cdr into-dir))
       (if (not (or dired-one-file into-dir))
          (error "Marked %s: target must be a directory: %s" operation target))
+      (if (and (not (file-directory-p (car fn-list)))
+               (not (file-directory-p target))
+               (directory-name-p target))
+          (error "%s: Target directory does not exist: %s" operation target))
       ;; rename-file bombs when moving directories unless we do this:
       (or into-dir (setq target (directory-file-name target)))
       (dired-create-files

Nick





reply via email to

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