aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/eshell/esh-cmd.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/eshell/esh-cmd.el')
-rw-r--r--lisp/eshell/esh-cmd.el63
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 @@
1;;; esh-cmd.el --- command invocation 1;;; esh-cmd.el --- command invocation
2 2
3;; Copyright (C) 1999-2011 Free Software Foundation, Inc. 3;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
4 4
5;; Author: John Wiegley <johnw@gnu.org> 5;; Author: John Wiegley <johnw@gnu.org>
6 6
@@ -108,7 +108,7 @@
108(require 'esh-ext) 108(require 'esh-ext)
109 109
110(eval-when-compile 110(eval-when-compile
111 (require 'cl) 111 (require 'cl-lib)
112 (require 'pcomplete)) 112 (require 'pcomplete))
113 113
114 114
@@ -236,10 +236,14 @@ return non-nil if the command is complex."
236 :group 'eshell-cmd) 236 :group 'eshell-cmd)
237 237
238(defcustom eshell-debug-command nil 238(defcustom eshell-debug-command nil
239 "If non-nil, enable debugging code. SSLLOOWW. 239 "If non-nil, enable Eshell debugging code.
240This option is only useful for reporting bugs. If you enable it, you 240This is slow, and only useful for debugging problems with Eshell.
241will have to visit the file 'eshell-cmd.el' and run the command 241If you change this without using customize after Eshell has loaded,
242\\[eval-buffer]." 242you must re-load 'esh-cmd.el'."
243 :initialize 'custom-initialize-default
244 :set (lambda (symbol value)
245 (set symbol value)
246 (load-library "esh-cmd"))
243 :type 'boolean 247 :type 'boolean
244 :group 'eshell-cmd) 248 :group 'eshell-cmd)
245 249
@@ -480,20 +484,22 @@ implemented via rewriting, rather than as a function."
480 (let ((body (car (last terms)))) 484 (let ((body (car (last terms))))
481 (setcdr (last terms 2) nil) 485 (setcdr (last terms 2) nil)
482 `(let ((for-items 486 `(let ((for-items
483 (append 487 (copy-tree
484 ,@(mapcar 488 (append
485 (lambda (elem) 489 ,@(mapcar
486 (if (listp elem) 490 (lambda (elem)
487 elem 491 (if (listp elem)
488 `(list ,elem))) 492 elem
489 (cdr (cddr terms))))) 493 `(list ,elem)))
490 (eshell-command-body '(nil)) 494 (cdr (cddr terms))))))
495 (eshell-command-body '(nil))
491 (eshell-test-body '(nil))) 496 (eshell-test-body '(nil)))
492 (while (consp for-items) 497 (while (car for-items)
493 (let ((,(intern (cadr terms)) (car for-items))) 498 (let ((,(intern (cadr terms)) (car for-items)))
494 (eshell-protect 499 (eshell-protect
495 ,(eshell-invokify-arg body t))) 500 ,(eshell-invokify-arg body t)))
496 (setq for-items (cdr for-items))) 501 (setcar for-items (cadr for-items))
502 (setcdr for-items (cddr for-items)))
497 (eshell-close-handles 503 (eshell-close-handles
498 eshell-last-command-status 504 eshell-last-command-status
499 (list 'quote eshell-last-command-result)))))) 505 (list 'quote eshell-last-command-result))))))
@@ -600,7 +606,7 @@ For an external command, it means an exit code of 0."
600 (list 606 (list
601 (if (<= (length pieces) 1) 607 (if (<= (length pieces) 1)
602 (car pieces) 608 (car pieces)
603 (assert (not eshell-in-pipeline-p)) 609 (cl-assert (not eshell-in-pipeline-p))
604 `(eshell-execute-pipeline (quote ,pieces)))))) 610 `(eshell-execute-pipeline (quote ,pieces))))))
605 (setq bp (cdr bp)))) 611 (setq bp (cdr bp))))
606 ;; `results' might be empty; this happens in the case of 612 ;; `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."
611 results (cdr results) 617 results (cdr results)
612 sep-terms (nreverse sep-terms)) 618 sep-terms (nreverse sep-terms))
613 (while results 619 (while results
614 (assert (car sep-terms)) 620 (cl-assert (car sep-terms))
615 (setq final (eshell-structure-basic-command 621 (setq final (eshell-structure-basic-command
616 'if (string= (car sep-terms) "&&") "if" 622 'if (string= (car sep-terms) "&&") "if"
617 `(eshell-protect ,(car results)) 623 `(eshell-protect ,(car results))
@@ -1022,7 +1028,7 @@ be finished later after the completion of an asynchronous subprocess."
1022 ;; `eshell-copy-tree' is needed here so that the test argument 1028 ;; `eshell-copy-tree' is needed here so that the test argument
1023 ;; doesn't get modified and thus always yield the same result. 1029 ;; doesn't get modified and thus always yield the same result.
1024 (when (car eshell-command-body) 1030 (when (car eshell-command-body)
1025 (assert (not synchronous-p)) 1031 (cl-assert (not synchronous-p))
1026 (eshell-do-eval (car eshell-command-body)) 1032 (eshell-do-eval (car eshell-command-body))
1027 (setcar eshell-command-body nil) 1033 (setcar eshell-command-body nil)
1028 (setcar eshell-test-body nil)) 1034 (setcar eshell-test-body nil))
@@ -1042,7 +1048,7 @@ be finished later after the completion of an asynchronous subprocess."
1042 ;; doesn't get modified and thus always yield the same result. 1048 ;; doesn't get modified and thus always yield the same result.
1043 (if (car eshell-command-body) 1049 (if (car eshell-command-body)
1044 (progn 1050 (progn
1045 (assert (not synchronous-p)) 1051 (cl-assert (not synchronous-p))
1046 (eshell-do-eval (car eshell-command-body))) 1052 (eshell-do-eval (car eshell-command-body)))
1047 (unless (car eshell-test-body) 1053 (unless (car eshell-test-body)
1048 (setcar eshell-test-body (eshell-copy-tree (car args)))) 1054 (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."
1197 (setq eshell-last-arguments args 1203 (setq eshell-last-arguments args
1198 eshell-last-command-name (eshell-stringify command)) 1204 eshell-last-command-name (eshell-stringify command))
1199 (run-hook-with-args 'eshell-prepare-command-hook) 1205 (run-hook-with-args 'eshell-prepare-command-hook)
1200 (assert (stringp eshell-last-command-name)) 1206 (cl-assert (stringp eshell-last-command-name))
1201 (if eshell-last-command-name 1207 (if eshell-last-command-name
1202 (or (run-hook-with-args-until-success 1208 (or (run-hook-with-args-until-success
1203 'eshell-named-command-hook eshell-last-command-name 1209 'eshell-named-command-hook eshell-last-command-name
@@ -1212,13 +1218,12 @@ COMMAND may result in an alias being executed, or a plain command."
1212 (let* ((sym (intern-soft (concat "eshell/" name))) 1218 (let* ((sym (intern-soft (concat "eshell/" name)))
1213 (file (symbol-file sym 'defun))) 1219 (file (symbol-file sym 'defun)))
1214 ;; If the function exists, but is defined in an eshell module 1220 ;; If the function exists, but is defined in an eshell module
1215 ;; that's not currently enabled, don't report it as found 1221 ;; that's not currently enabled, don't report it as found.
1216 (if (and file 1222 (if (and file
1217 (string-match "\\(em\\|esh\\)-\\(.*\\)\\(\\.el\\)?\\'" file)) 1223 (setq file (file-name-base file))
1224 (string-match "\\`\\(em\\|esh\\)-\\([[:alnum:]]+\\)\\'" file))
1218 (let ((module-sym 1225 (let ((module-sym
1219 (intern (file-name-sans-extension 1226 (intern (concat "eshell-" (match-string 2 file)))))
1220 (file-name-nondirectory
1221 (concat "eshell-" (match-string 2 file)))))))
1222 (if (and (functionp sym) 1227 (if (and (functionp sym)
1223 (or (null module-sym) 1228 (or (null module-sym)
1224 (eshell-using-module module-sym) 1229 (eshell-using-module module-sym)