comparison lisp/progmodes/sh-script.el @ 69149:b5043066337b

(sh-mode): Fix bug: Arrange to use the default shell if filename is not available.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Sat, 25 Feb 2006 11:23:12 +0000
parents d148e515073b
children 60a94b1ec37e 8a1ee48a8386
comparison
equal deleted inserted replaced
69148:ed7ce86c68db 69149:b5043066337b
1428 skeleton-newline-indent-rigidly t 1428 skeleton-newline-indent-rigidly t
1429 sh-indent-supported-here nil) 1429 sh-indent-supported-here nil)
1430 (set (make-local-variable 'parse-sexp-ignore-comments) t) 1430 (set (make-local-variable 'parse-sexp-ignore-comments) t)
1431 ;; Parse or insert magic number for exec, and set all variables depending 1431 ;; Parse or insert magic number for exec, and set all variables depending
1432 ;; on the shell thus determined. 1432 ;; on the shell thus determined.
1433 (let ((interpreter 1433 (sh-set-shell
1434 (save-excursion 1434 (cond ((save-excursion
1435 (goto-char (point-min)) 1435 (goto-char (point-min))
1436 (cond ((looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)") 1436 (looking-at "#![ \t]?\\([^ \t\n]*/bin/env[ \t]\\)?\\([^ \t\n]+\\)"))
1437 (match-string 2)) 1437 (match-string 2))
1438 ((and buffer-file-name 1438 ((not buffer-file-name)
1439 (string-match "\\.m?spec\\'" buffer-file-name)) 1439 sh-shell-file)
1440 "rpm"))))) 1440 ;; Checks that use `buffer-file-name' follow.
1441 (unless interpreter 1441 ((string-match "\\.m?spec\\'" buffer-file-name)
1442 (setq interpreter 1442 "rpm")
1443 (cond ((string-match "[.]sh\\>" buffer-file-name) 1443 ((string-match "[.]sh\\>" buffer-file-name)
1444 "sh") 1444 "sh")
1445 ((string-match "[.]bash\\>" buffer-file-name) 1445 ((string-match "[.]bash\\>" buffer-file-name)
1446 "bash") 1446 "bash")
1447 ((string-match "[.]ksh\\>" buffer-file-name) 1447 ((string-match "[.]ksh\\>" buffer-file-name)
1448 "ksh") 1448 "ksh")
1449 ((string-match "[.]csh\\>" buffer-file-name) 1449 ((string-match "[.]csh\\>" buffer-file-name)
1450 "csh")))) 1450 "csh")
1451 (sh-set-shell (or interpreter sh-shell-file) nil nil)) 1451 (t
1452 sh-shell-file))
1453 nil nil)
1452 (run-mode-hooks 'sh-mode-hook)) 1454 (run-mode-hooks 'sh-mode-hook))
1453 1455
1454 ;;;###autoload 1456 ;;;###autoload
1455 (defalias 'shell-script-mode 'sh-mode) 1457 (defalias 'shell-script-mode 'sh-mode)
1456 1458