karlheg> I had a "test-config" directory where I ran configure, and a build
karlheg> failed... then I used `dired' to rm it, said yes to the
"recurse"
karlheg> question.
karlheg> Now the contents of <xemacs checkout>/etc/* are gone. This has
karlheg> happened before and I think it's dired doing it.
Judging by the code, you are correct:
(defun dired-recursive-delete-directory (fn)
;; Recursively deletes directory FN, and all of its contents.
(let* ((fn (expand-file-name fn))
...
(let ((files (directory-files fn t)))
(while files
(let ((file (car files)))
(if (not (member (file-name-nondirectory file)
'("." "..")))
(if (file-directory-p file)
(dired-recursive-delete-directory file)
(delete-file file)))
(setq files (cdr files))))
(delete-directory fn))))))
The test:
(if (file-directory-p file)
Is broken:
ls -lagd .tcshrc Work x
-rw-r--r-- 1 gshapiro gshapiro 599
Jan 17 1999 .tcshrc
drwx------ 4 gshapiro gshapiro 512 May 29 17:18 Work
lrwxr-xr-x 1 gshapiro gshapiro 4 May 29 23:02 x -> Work
ELISP> (file-directory-p (expand-file-name "~/Work"))
t
ELISP> (file-directory-p (expand-file-name "~/.tcshrc"))
nil
ELISP> (file-directory-p (expand-file-name "~/x"))
t
So when it recurses, the:
(let ((files (directory-files fn t)))
catches the files in the symlinked directory.
This should be enough to fix it:
--- dired.el~ Thu Apr 5 04:53:37 2001
+++ dired.el Tue May 29 23:06:42 2001
@@ -3608,7 +3608,8 @@
(let ((file (car files)))
(if (not (member (file-name-nondirectory file)
'("." "..")))
- (if (file-directory-p file)
+ (if (and (file-directory-p file)
+ (not (file-symlink-p file)))
(dired-recursive-delete-directory file)
(delete-file file)))
(setq files (cdr files))))