Function: sh--guess-shell

sh--guess-shell is a byte-compiled function defined in sh-script.el.gz.

Signature

(sh--guess-shell)

Documentation

Guess the shell used in the current buffer.

Return the name of the shell suitable for sh-set-shell.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sh-script.el.gz
(defun sh--guess-shell ()
  "Guess the shell used in the current buffer.
Return the name of the shell suitable for `sh-set-shell'."
  (cond ((save-excursion
           (goto-char (point-min))
           (looking-at auto-mode-interpreter-regexp))
         (match-string 2))
        ((not buffer-file-name) sh-shell-file)
        ;; Checks that use `buffer-file-name' follow.
        ((string-match "\\.m?spec\\'" buffer-file-name) "rpm")
        ((string-match "[.]sh\\>"     buffer-file-name) "sh")
        ((string-match "[.]bash\\(rc\\)?\\>"   buffer-file-name) "bash")
        ((string-match "[.]ksh\\>"    buffer-file-name) "ksh")
        ((string-match "[.]mkshrc\\>" buffer-file-name) "mksh")
        ((string-match "[.]t?csh\\(rc\\)?\\>" buffer-file-name) "csh")
        ((string-match "[.]zsh\\(rc\\|env\\)?\\>" buffer-file-name) "zsh")
	((equal (file-name-nondirectory buffer-file-name) ".profile") "sh")
	((equal (file-name-nondirectory buffer-file-name) "PKGBUILD") "bash")
        (t sh-shell-file)))