(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
(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
(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>."
(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))))
(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)))))))