]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/em-unix.el
Update copyright year to 2015
[gnu-emacs] / lisp / eshell / em-unix.el
index 52d2b4d2a2ddb262fafa2fb8bf1abb7dd2676820..c50a874629bae22cecd0a0e9b31e25ecc90f572b 100644 (file)
@@ -1,6 +1,6 @@
 ;;; em-unix.el --- UNIX command aliases  -*- lexical-binding:t -*-
 
-;; Copyright (C) 1999-2013 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2015 Free Software Foundation, Inc.
 
 ;; Author: John Wiegley <johnw@gnu.org>
 
@@ -195,12 +195,12 @@ Otherwise, Emacs will attempt to use rsh to invoke du on the remote machine."
       (Info-menu (car args))
       (setq args (cdr args)))))
 
-(defun eshell-remove-entries (path files &optional top-level)
-  "From PATH, remove all of the given FILES, perhaps interactively."
+(defun eshell-remove-entries (files &optional toplevel)
+  "Remove all of the given FILES, perhaps interactively."
   (while files
     (if (string-match "\\`\\.\\.?\\'"
                      (file-name-nondirectory (car files)))
-       (if top-level
+       (if toplevel
            (eshell-error "rm: cannot remove `.' or `..'\n"))
       (if (and (file-directory-p (car files))
               (not (file-symlink-p (car files))))
@@ -284,18 +284,21 @@ Remove (unlink) the FILE(s).")
                                             entry)))))
           (eshell-funcalln 'unintern entry)))
        ((stringp entry)
-        (if (and (file-directory-p entry)
-                 (not (file-symlink-p entry)))
-            (if (or em-recursive
-                    eshell-rm-removes-directories)
-                (if (or em-preview
-                        (not em-interactive)
-                        (y-or-n-p
-                         (format "rm: descend into directory `%s'? "
-                                 entry)))
-                    (eshell-remove-entries nil (list entry) t))
-              (eshell-error (format "rm: %s: is a directory\n" entry)))
-          (eshell-remove-entries nil (list entry) t)))))
+        ;; -f should silently ignore missing files (bug#15373).
+        (unless (and force-removal
+                     (not (file-exists-p entry)))
+          (if (and (file-directory-p entry)
+                   (not (file-symlink-p entry)))
+              (if (or em-recursive
+                      eshell-rm-removes-directories)
+                  (if (or em-preview
+                          (not em-interactive)
+                          (y-or-n-p
+                           (format "rm: descend into directory `%s'? "
+                                   entry)))
+                    (eshell-remove-entries (list entry) t))
+                (eshell-error (format "rm: %s: is a directory\n" entry)))
+            (eshell-remove-entries (list entry) t))))))
      (setq args (cdr args)))
    nil))
 
@@ -458,6 +461,8 @@ Remove the DIRECTORY(ies), if they are empty.")
           (eshell-parse-command
            (format "tar %s %s" tar-args archive) args))))
 
+(defvar ange-cache)                    ; XEmacs?  See esh-util
+
 ;; this is to avoid duplicating code...
 (defmacro eshell-mvcpln-template (command action func query-var
                                          force-var &optional preserve)