From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sven Joachim Newsgroups: gmane.emacs.bugs Subject: bug#4739: 23.1.50; recursive delete fails Date: Fri, 23 Oct 2009 10:12:32 +0200 Message-ID: <87eiouo7f3.fsf@turtle.gmx.de> References: <87eip3ksyi.fsf@turtle.gmx.de> Reply-To: Sven Joachim , 4739@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1256286721 7571 80.91.229.12 (23 Oct 2009 08:32:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 23 Oct 2009 08:32:01 +0000 (UTC) To: 4739@emacsbugs.donarmstrong.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Oct 23 10:31:54 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N1FUe-0006Xk-Um for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Oct 2009 10:27:29 +0200 Original-Received: from localhost ([127.0.0.1]:40296 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1FUe-0001kV-76 for geb-bug-gnu-emacs@m.gmane.org; Fri, 23 Oct 2009 04:27:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N1FUY-0001kB-F3 for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2009 04:27:22 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N1FUT-0001ia-NX for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2009 04:27:22 -0400 Original-Received: from [199.232.76.173] (port=43713 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N1FUT-0001iV-Ib for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2009 04:27:17 -0400 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:41975) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1N1FUT-0001AZ-5N for bug-gnu-emacs@gnu.org; Fri, 23 Oct 2009 04:27:17 -0400 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with ESMTP id n9N8RDnt016648; Fri, 23 Oct 2009 01:27:13 -0700 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.14.3/8.14.3/Submit) id n9N8K8Xg015554; Fri, 23 Oct 2009 01:20:08 -0700 Resent-Date: Fri, 23 Oct 2009 01:20:08 -0700 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Sven Joachim Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs 2Resent-Date: Fri, 23 Oct 2009 08:20:08 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 4739 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 4739-submit@emacsbugs.donarmstrong.com id=B4739.125628556314512 (code B ref 4739); Fri, 23 Oct 2009 08:20:08 +0000 Original-Received: (at 4739) by emacsbugs.donarmstrong.com; 23 Oct 2009 08:12:43 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from mail.gmx.net (mail.gmx.net [213.165.64.20]) by rzlab.ucr.edu (8.14.3/8.14.3/Debian-5) with SMTP id n9N8Cecv014508 for <4739@emacsbugs.donarmstrong.com>; Fri, 23 Oct 2009 01:12:42 -0700 Original-Received: (qmail invoked by alias); 23 Oct 2009 08:12:35 -0000 Original-Received: from p54863A21.dip.t-dialin.net (EHLO turtle.gmx.de) [84.134.58.33] by mail.gmx.net (mp069) with SMTP; 23 Oct 2009 10:12:35 +0200 X-Authenticated: #28250155 X-Provags-ID: V01U2FsdGVkX18IbDgNLlYIKAPR7/tXdmWFJLAPLVx0lFs2biJ/Ie GlFdKeygJ2TPXi Original-Received: by turtle.gmx.de (Postfix, from userid 1000) id 8B63D354B4; Fri, 23 Oct 2009 10:12:33 +0200 (CEST) In-Reply-To: <87eip3ksyi.fsf@turtle.gmx.de> (Sven Joachim's message of "Fri, 16 Oct 2009 22:02:45 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-Y-GMX-Trusted: 0 X-FuHaFi: 0.49 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) Resent-Date: Fri, 23 Oct 2009 04:27:21 -0400 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:32180 Archived-At: tags 4739 patch On 2009-10-16 22:02 +0200, Sven Joachim wrote: > In the following situation Emacs signals an error: > > $ mkdir -p /tmp/test > $ ln -s /tmp /tmp/test > $ emacs -Q /tmp > > Now move point to the 'test' directory, type 'D' and confirm that you > want to delete the directory recursively. An error message appears in > the echo area: > (file-error Removing directory Not a directory /tmp/test/tmp) Here is a patch that should fix this issue by testing whether the /tmp/test/tmp subdirectory is actually a symlink. It uses the same trick as the dired-delete-file function to test for that condition: --8<---------------cut here---------------start------------->8--- diff --git a/lisp/files.el b/lisp/files.el index ce9791f..6c43131 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -4660,7 +4660,10 @@ If RECURSIVE is non-nil, all files in DIRECTORY are deleted as well." (if (and recursive (not (file-symlink-p directory))) (mapc (lambda (file) - (if (file-directory-p file) + ;; This test is equivalent to + ;; (and (file-directory-p file) (not (file-symlink-p file))) + ;; but more efficient + (if (eq t (car (file-attributes file))) (delete-directory file recursive) (delete-file file))) ;; We do not want to delete "." and "..". --8<---------------cut here---------------end--------------->8--- Suggested ChangeLog entry: 2009-10-23 Sven Joachim * files.el (delete-directory): Don't fail recursive deletions if the directory contains a symlink to another directory (Bug #4739).