]> code.delx.au - gnu-emacs/blobdiff - lisp/eshell/esh-ext.el
* em-term.el (eshell-term-name): Default to term-term-name. (Bug#12485)
[gnu-emacs] / lisp / eshell / esh-ext.el
index f025c66df32a5b37ceb301fb11e950d64782218b..e48213c54d6c74da7bc0d97b99fae61cac52f794 100644 (file)
 (provide 'esh-ext)
 
 (eval-when-compile
-  (require 'cl)
+  (require 'cl-lib)
   (require 'esh-cmd))
 (require 'esh-util)
+(require 'esh-opt)
 
 (defgroup eshell-ext nil
   "External commands are invoked when operating system executables are
@@ -188,6 +189,7 @@ all the output from the remote command, and sends it all at once,
 causing the user to wonder if anything's really going on..."
   (let ((outbuf (generate-new-buffer " *eshell remote output*"))
        (errbuf (generate-new-buffer " *eshell remote error*"))
+       (command (or (file-remote-p command 'localname) command))
        (exitcode 1))
     (unwind-protect
        (progn
@@ -205,10 +207,15 @@ causing the user to wonder if anything's really going on..."
 (defun eshell-external-command (command args)
   "Insert output from an external COMMAND, using ARGS."
   (setq args (eshell-stringify-list (eshell-flatten-list args)))
-  (if (file-remote-p default-directory)
-      (eshell-remote-command command args))
-  (let ((interp (eshell-find-interpreter command)))
-    (assert interp)
+  (let ((interp (eshell-find-interpreter
+                command
+                ;; `eshell-find-interpreter' does not work correctly
+                ;; for Tramp file name syntax.  But we don't need to
+                ;; know the interpreter in that case, therefore the
+                ;; check is suppressed.
+                (or (and (stringp command) (file-remote-p command))
+                    (file-remote-p default-directory)))))
+    (cl-assert interp)
     (if (functionp (car interp))
        (apply (car interp) (append (cdr interp) args))
       (eshell-gather-process-output
@@ -224,20 +231,15 @@ causing the user to wonder if anything's really going on..."
 Adds the given PATH to $PATH.")
    (if args
        (progn
-        (if prepend
-            (setq args (nreverse args)))
-        (while args
-          (setenv "PATH"
-                  (if prepend
-                      (concat (car args) path-separator
-                              (getenv "PATH"))
-                    (concat (getenv "PATH") path-separator
-                            (car args))))
-          (setq args (cdr args))))
-     (let ((paths (parse-colon-path (getenv "PATH"))))
-       (while paths
-        (eshell-printn (car paths))
-        (setq paths (cdr paths)))))))
+        (setq eshell-path-env (getenv "PATH")
+              args (mapconcat 'identity args path-separator)
+              eshell-path-env
+              (if prepend
+                  (concat args path-separator eshell-path-env)
+                (concat eshell-path-env path-separator args)))
+        (setenv "PATH" eshell-path-env))
+     (dolist (dir (parse-colon-path (getenv "PATH")))
+       (eshell-printn dir)))))
 
 (put 'eshell/addpath 'eshell-no-numeric-conversions t)