GNU bug report logs -
#38707
dired-do-rename doesn't check for "/" !
Previous Next
Reported by: 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Date: Sun, 22 Dec 2019 16:38:01 UTC
Severity: minor
Tags: fixed
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 38707 in the body.
You can then email your comments to 38707 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#38707
; Package
emacs
.
(Sun, 22 Dec 2019 16:38:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sun, 22 Dec 2019 16:38:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
R runs the command dired-do-rename (found in dired-mode-map), which is
an interactive autoloaded compiled Lisp function in ‘dired-aux.el’.
But it has a big bug.
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 .
Real "mv" doesn't have this bug.
$ mv k /tmp/p/
mv: cannot create regular file '/tmp/p/': Not a directory
dired-do-rename perhaps under the hood does the "mv" action, but instead
of reporting the failure, tries again with the final slash removed!
emacs-version "26.3"
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#38707
; Package
emacs
.
(Tue, 24 Dec 2019 04:30:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 38707 <at> debbugs.gnu.org (full text, mbox):
Dan Jacobson <jidanni <at> 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
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#38707
; Package
emacs
.
(Thu, 06 Aug 2020 10:15:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 38707 <at> debbugs.gnu.org (full text, mbox):
Nick Helm <nick <at> tenpoint.co.nz> writes:
> 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?
[...]
> + (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))
I think this makes sense, so I've applied it to Emacs 28.1. However, it
is a slight behavioural change -- previously you could enter, say
"/tmp/bar/" (when moving one file), and it would move the file to the
file "/tmp/bar".
I think the new behaviour is better (i.e., bugging out), but if people
complain for some reason, then it should perhaps be reverted.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
Added tag(s) fixed.
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 06 Aug 2020 10:15:01 GMT)
Full text and
rfc822 format available.
bug marked as fixed in version 28.1, send any further explanations to
38707 <at> debbugs.gnu.org and 積丹尼 Dan Jacobson <jidanni <at> jidanni.org>
Request was from
Lars Ingebrigtsen <larsi <at> gnus.org>
to
control <at> debbugs.gnu.org
.
(Thu, 06 Aug 2020 10:15:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 03 Sep 2020 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 3 years and 229 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.