diff options
Diffstat (limited to 'lisp/eshell/esh-ext.el')
| -rw-r--r-- | lisp/eshell/esh-ext.el | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/lisp/eshell/esh-ext.el b/lisp/eshell/esh-ext.el index c4e4c000bda..474e536de2e 100644 --- a/lisp/eshell/esh-ext.el +++ b/lisp/eshell/esh-ext.el @@ -125,9 +125,10 @@ Each member is a cons cell of the form: (MATCH . INTERPRETER) -MATCH should be a regexp, which is matched against the command name, -or a function. If either returns a non-nil value, then INTERPRETER -will be used for that command. +MATCH should be a regexp, which is matched against the command +name, or a function of arity 2 receiving the COMMAND and its +ARGS (a list). If either returns a non-nil value, then +INTERPRETER will be used for that command. If INTERPRETER is a string, it will be called as the command name, with the original command name passed as the first argument, with all @@ -215,6 +216,7 @@ causing the user to wonder if anything's really going on..." (setq args (eshell-stringify-list (eshell-flatten-list args))) (let ((interp (eshell-find-interpreter command + args ;; `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 @@ -267,7 +269,7 @@ Return nil, or a list of the form: (list (match-string 1) file))))))) -(defun eshell-find-interpreter (file &optional no-examine-p) +(defun eshell-find-interpreter (file args &optional no-examine-p) "Find the command interpreter with which to execute FILE. If NO-EXAMINE-P is non-nil, FILE will not be inspected for a script line of the form #!<interp>." @@ -277,8 +279,9 @@ line of the form #!<interp>." (dolist (possible eshell-interpreter-alist) (cond ((functionp (car possible)) - (and (funcall (car possible) file) - (throw 'found (cdr possible)))) + (let ((fn (car possible))) + (and (funcall fn file args) + (throw 'found (cdr possible))))) ((stringp (car possible)) (and (string-match (car possible) file) (throw 'found (cdr possible)))) @@ -312,7 +315,7 @@ line of the form #!<interp>." (setq interp (eshell-script-interpreter fullname)) (if interp (setq interp - (cons (car (eshell-find-interpreter (car interp) t)) + (cons (car (eshell-find-interpreter (car interp) args t)) (cdr interp))))) (or interp (list fullname))))))) |
