]> git.eshelyaron.com Git - emacs.git/commitdiff
Make dired-do-rename refuse to rename . and ..
authorLars Ingebrigtsen <larsi@gnus.org>
Sat, 24 Sep 2022 13:27:50 +0000 (15:27 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sat, 24 Sep 2022 13:27:50 +0000 (15:27 +0200)
* lisp/dired-aux.el (dired-do-rename): Refuse to rename . and ..
(bug#52004).  This used to error out after renaming.

lisp/dired-aux.el

index f870494e93edb98f5d48cbda3ee20fef7f4aef52..9add96c260836d8f3e1e4aabf22cb52c75727773 100644 (file)
@@ -2880,6 +2880,10 @@ of `dired-dwim-target', which see.
 
 Also see `dired-do-revert-buffer'."
   (interactive "P")
+  (when (seq-find (lambda (file)
+                    (member (file-name-nondirectory file) '("." "..")))
+                  (dired-get-marked-files nil arg))
+    (user-error "Can't rename \".\" or \"..\" files"))
   (dired-do-create-files 'move #'dired-rename-file
                         "Move" arg dired-keep-marker-rename "Rename"))