diff options
Diffstat (limited to 'lisp/eshell/esh-cmd.el')
-rw-r--r-- | lisp/eshell/esh-cmd.el | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/lisp/eshell/esh-cmd.el b/lisp/eshell/esh-cmd.el index 7b90797eb43..e6e89d83b7c 100644 --- a/lisp/eshell/esh-cmd.el +++ b/lisp/eshell/esh-cmd.el @@ -1,6 +1,6 @@ ;;; esh-cmd.el --- command invocation -;; Copyright (C) 1999-2011 Free Software Foundation, Inc. +;; Copyright (C) 1999-2012 Free Software Foundation, Inc. ;; Author: John Wiegley <johnw@gnu.org> @@ -108,7 +108,7 @@ (require 'esh-ext) (eval-when-compile - (require 'cl) + (require 'cl-lib) (require 'pcomplete)) @@ -236,10 +236,14 @@ return non-nil if the command is complex." :group 'eshell-cmd) (defcustom eshell-debug-command nil - "If non-nil, enable debugging code. SSLLOOWW. -This option is only useful for reporting bugs. If you enable it, you -will have to visit the file 'eshell-cmd.el' and run the command -\\[eval-buffer]." + "If non-nil, enable Eshell debugging code. +This is slow, and only useful for debugging problems with Eshell. +If you change this without using customize after Eshell has loaded, +you must re-load 'esh-cmd.el'." + :initialize 'custom-initialize-default + :set (lambda (symbol value) + (set symbol value) + (load-library "esh-cmd")) :type 'boolean :group 'eshell-cmd) @@ -480,20 +484,22 @@ implemented via rewriting, rather than as a function." (let ((body (car (last terms)))) (setcdr (last terms 2) nil) `(let ((for-items - (append - ,@(mapcar - (lambda (elem) - (if (listp elem) - elem - `(list ,elem))) - (cdr (cddr terms))))) - (eshell-command-body '(nil)) + (copy-tree + (append + ,@(mapcar + (lambda (elem) + (if (listp elem) + elem + `(list ,elem))) + (cdr (cddr terms)))))) + (eshell-command-body '(nil)) (eshell-test-body '(nil))) - (while (consp for-items) - (let ((,(intern (cadr terms)) (car for-items))) - (eshell-protect - ,(eshell-invokify-arg body t))) - (setq for-items (cdr for-items))) + (while (car for-items) + (let ((,(intern (cadr terms)) (car for-items))) + (eshell-protect + ,(eshell-invokify-arg body t))) + (setcar for-items (cadr for-items)) + (setcdr for-items (cddr for-items))) (eshell-close-handles eshell-last-command-status (list 'quote eshell-last-command-result)))))) @@ -600,7 +606,7 @@ For an external command, it means an exit code of 0." (list (if (<= (length pieces) 1) (car pieces) - (assert (not eshell-in-pipeline-p)) + (cl-assert (not eshell-in-pipeline-p)) `(eshell-execute-pipeline (quote ,pieces)))))) (setq bp (cdr bp)))) ;; `results' might be empty; this happens in the case of @@ -611,7 +617,7 @@ For an external command, it means an exit code of 0." results (cdr results) sep-terms (nreverse sep-terms)) (while results - (assert (car sep-terms)) + (cl-assert (car sep-terms)) (setq final (eshell-structure-basic-command 'if (string= (car sep-terms) "&&") "if" `(eshell-protect ,(car results)) @@ -1022,7 +1028,7 @@ be finished later after the completion of an asynchronous subprocess." ;; `eshell-copy-tree' is needed here so that the test argument ;; doesn't get modified and thus always yield the same result. (when (car eshell-command-body) - (assert (not synchronous-p)) + (cl-assert (not synchronous-p)) (eshell-do-eval (car eshell-command-body)) (setcar eshell-command-body nil) (setcar eshell-test-body nil)) @@ -1042,7 +1048,7 @@ be finished later after the completion of an asynchronous subprocess." ;; doesn't get modified and thus always yield the same result. (if (car eshell-command-body) (progn - (assert (not synchronous-p)) + (cl-assert (not synchronous-p)) (eshell-do-eval (car eshell-command-body))) (unless (car eshell-test-body) (setcar eshell-test-body (eshell-copy-tree (car args)))) @@ -1197,7 +1203,7 @@ COMMAND may result in an alias being executed, or a plain command." (setq eshell-last-arguments args eshell-last-command-name (eshell-stringify command)) (run-hook-with-args 'eshell-prepare-command-hook) - (assert (stringp eshell-last-command-name)) + (cl-assert (stringp eshell-last-command-name)) (if eshell-last-command-name (or (run-hook-with-args-until-success 'eshell-named-command-hook eshell-last-command-name @@ -1212,13 +1218,12 @@ COMMAND may result in an alias being executed, or a plain command." (let* ((sym (intern-soft (concat "eshell/" name))) (file (symbol-file sym 'defun))) ;; If the function exists, but is defined in an eshell module - ;; that's not currently enabled, don't report it as found + ;; that's not currently enabled, don't report it as found. (if (and file - (string-match "\\(em\\|esh\\)-\\(.*\\)\\(\\.el\\)?\\'" file)) + (setq file (file-name-base file)) + (string-match "\\`\\(em\\|esh\\)-\\([[:alnum:]]+\\)\\'" file)) (let ((module-sym - (intern (file-name-sans-extension - (file-name-nondirectory - (concat "eshell-" (match-string 2 file))))))) + (intern (concat "eshell-" (match-string 2 file))))) (if (and (functionp sym) (or (null module-sym) (eshell-using-module module-sym) |