Function: eshell-script-interpreter

eshell-script-interpreter is a byte-compiled function defined in esh-ext.el.gz.

Signature

(eshell-script-interpreter FILE)

Documentation

Extract the script to run from FILE, if it has #!<interp> in it.

Return nil, or a list of the form:

  (INTERPRETER [ARGS] FILE)

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-ext.el.gz
(defun eshell-script-interpreter (file)
  "Extract the script to run from FILE, if it has #!<interp> in it.
Return nil, or a list of the form:

  (INTERPRETER [ARGS] FILE)"
  (let ((maxlen eshell-command-interpreter-max-length))
    (if (and (file-readable-p file)
	     (file-regular-p file))
	(with-temp-buffer
	  (insert-file-contents-literally file nil 0 maxlen)
	  (if (looking-at "#![ \t]*\\([^ \r\t\n]+\\)\\([ \t]+\\(.+\\)\\)?")
	      (if (match-string 3)
		  (list (match-string 1)
			(match-string 3)
			file)
		(list (match-string 1)
		      file)))))))