From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Nick Helm Newsgroups: gmane.emacs.bugs Subject: bug#38707: dired-do-rename doesn't check for "/" ! Date: Tue, 24 Dec 2019 17:28:55 +1300 Message-ID: References: <87d0cge2pl.5.fsf@jidanni.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="200362"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (darwin) To: 38707@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Dec 24 05:30:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1ijbpj-000pwv-3E for geb-bug-gnu-emacs@m.gmane.org; Tue, 24 Dec 2019 05:30:11 +0100 Original-Received: from localhost ([::1]:35970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijbph-0004h8-UG for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 Dec 2019 23:30:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34504) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ijbpc-0004gu-9j for bug-gnu-emacs@gnu.org; Mon, 23 Dec 2019 23:30:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ijbpb-000090-0f for bug-gnu-emacs@gnu.org; Mon, 23 Dec 2019 23:30:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:45930) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ijbpa-00005X-6W for bug-gnu-emacs@gnu.org; Mon, 23 Dec 2019 23:30:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ijbpa-0006Pe-1o for bug-gnu-emacs@gnu.org; Mon, 23 Dec 2019 23:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Nick Helm Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 24 Dec 2019 04:30:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 38707 X-GNU-PR-Package: emacs Original-Received: via spool by 38707-submit@debbugs.gnu.org id=B38707.157716174824552 (code B ref 38707); Tue, 24 Dec 2019 04:30:01 +0000 Original-Received: (at 38707) by debbugs.gnu.org; 24 Dec 2019 04:29:08 +0000 Original-Received: from localhost ([127.0.0.1]:51903 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ijboh-0006Nv-Q5 for submit@debbugs.gnu.org; Mon, 23 Dec 2019 23:29:08 -0500 Original-Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42887) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ijbof-0006NR-ER for 38707@debbugs.gnu.org; Mon, 23 Dec 2019 23:29:06 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id EA28521FBA for <38707@debbugs.gnu.org>; Mon, 23 Dec 2019 23:28:59 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 23 Dec 2019 23:28:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tenpoint.co.nz; h=to:subject:references:from:date:in-reply-to:message-id :mime-version:content-type; s=fm2; bh=QXU2ovZfBw5IlCrSyN0CHq9h/1 hA56KFeWK7Hd8gHGU=; b=eVP4hTc1SOxnr2w3X9hHq6rROwBlxlOdQSUYVd9meu yD7Xr8N+Fb91rOTo0AqHxtcfRu6YLRA61aaRY8f6fu7RyvqFiTtXxEjl0YHXyHKc qD9mQrgLUYuo4vWBgBel40vREgA4lhTr+j9P4aH6TvxhW5yb/u14jjEvRCzUBdI0 lMsgtJ3qoUQ2SdPsTvMYF5uPznN84kY1e7nQEGw7NwxKG06JP+f+DgAX9tPfD3qf Mldxp1PuO2egfLOrQEyPr/RgOKD9t4NphxCodbQ3nhpSJEO0kWQGvO4Wjec8N6qk MbPMsoT4m/CF0ex0+axjXkNEU0d+ibX9JkHHVfN01bEA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=QXU2ov ZfBw5IlCrSyN0CHq9h/1hA56KFeWK7Hd8gHGU=; b=fi7ocDxSi/OXv7pGH2Bcws eLh7n4CrUoodW+cuzUT2iPbce7wL//Y0Bd4MMoFTTqenI2nZ6wx+p3K8ijmrgULA DIbqie6XSovIaOUcrlndtzgd4FiFvqebYjFOa6LP3HiBON4MTFc0dsg+8aFgR0el gIQb/P9BtDt1LWiQqynblY+CLC96BAVvny65GPxSWQ3DAhdXGaMqicdoTlh5mmDp wANCD0QSGeagmpMKtCdqSehepTV1Xf+EOwJqSzxV9SbXO2F2Hv0kdKcZbWSGrmH8 lyeYaNM2aCfiaXhg14zEK/oC7FPeOhJnl5oJI/x6NbP2NPKQtRiT0M8HTqnqCERQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvddvuddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefvufhfhfffjgfkfgggtgesthdtre dttdertdenucfhrhhomheppfhitghkucfjvghlmhcuoehnihgtkhesthgvnhhpohhinhht rdgtohdrnhiiqeenucfkphepuddvhedrvdefledruddvtddrudeltdenucfrrghrrghmpe hmrghilhhfrhhomhepnhhitghksehtvghnphhoihhnthdrtghordhniienucevlhhushht vghrufhiiigvpedt X-ME-Proxy: Original-Received: from jupiter.local (125-239-120-190-vdsl.sparkbb.co.nz [125.239.120.190]) by mail.messagingengine.com (Postfix) with ESMTPA id AD6A58005C for <38707@debbugs.gnu.org>; Mon, 23 Dec 2019 23:28:58 -0500 (EST) In-Reply-To: <87d0cge2pl.5.fsf@jidanni.org> ("=?UTF-8?Q?=E7=A9=8D=E4=B8=B9=E5=B0=BC?= Dan Jacobson"'s message of "Mon, 23 Dec 2019 00:37:26 +0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:173698 Archived-At: Dan Jacobson 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