mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-04 06:31:13 -08:00
Support more complex env invocations in shebang lines
This is not an exact re-implementation of what env accepts, but hopefully it should be "good enough". Example of known limitation: we assume that arguments for --long-options will be set with '=', but that is not necessarily the case. '--unset' (mandatory argument) can be passed as '--unset=VAR' or '--unset VAR', but '--default-signal' (optional argument) requires an '=' sign. For bug#64939. * lisp/files.el (auto-mode-interpreter-regexp): Account for supplementary arguments passed beside -S/--split-string. * test/lisp/files-tests.el (files-tests-auto-mode-interpreter): Test some of these combinations.
This commit is contained in:
parent
de6f7f3c86
commit
ecb9641ecb
2 changed files with 14 additions and 2 deletions
|
|
@ -3274,7 +3274,13 @@ and `inhibit-local-variables-suffixes'. If
|
|||
;; Optional group 1: env(1) invocation.
|
||||
"\\("
|
||||
"[^ \t\n]*/bin/env[ \t]*"
|
||||
"\\(?:-S[ \t]*\\|--split-string\\(?:=\\|[ \t]*\\)\\)?"
|
||||
;; Within group 1: possible -S/--split-string.
|
||||
"\\(?:"
|
||||
;; -S/--split-string
|
||||
"\\(?:-[0a-z]*S[ \t]*\\|--split-string=\\)"
|
||||
;; More env arguments.
|
||||
"\\(?:-[^ \t\n]+[ \t]+\\)*"
|
||||
"\\)?"
|
||||
"\\)?"
|
||||
;; Group 2: interpreter.
|
||||
"\\([^ \t\n]+\\)"))
|
||||
|
|
|
|||
|
|
@ -1687,8 +1687,14 @@ set to."
|
|||
(files-tests--check-shebang "#!/usr/bin/env python" 'python-base-mode)
|
||||
(files-tests--check-shebang "#!/usr/bin/env python3" 'python-base-mode)
|
||||
;; Invocation through env, with supplementary arguments.
|
||||
(files-tests--check-shebang "#!/usr/bin/env --split-string=bash -eux" 'sh-base-mode 'bash)
|
||||
(files-tests--check-shebang "#!/usr/bin/env --split-string=-iv --default-signal bash -eux" 'sh-base-mode 'bash)
|
||||
(files-tests--check-shebang "#!/usr/bin/env -S awk -v FS=\"\\t\" -v OFS=\"\\t\" -f" 'awk-mode)
|
||||
(files-tests--check-shebang "#!/usr/bin/env -S make -f" 'makefile-mode))
|
||||
(files-tests--check-shebang "#!/usr/bin/env -S make -f" 'makefile-mode)
|
||||
(files-tests--check-shebang "#!/usr/bin/env -S-vi bash -eux" 'sh-base-mode 'bash)
|
||||
(files-tests--check-shebang "#!/usr/bin/env -ivS --default-signal=INT bash -eux" 'sh-base-mode 'bash)
|
||||
(files-tests--check-shebang "#!/usr/bin/env -ivS --default-signal bash -eux" 'sh-base-mode 'bash)
|
||||
(files-tests--check-shebang "#!/usr/bin/env -vS -uFOOBAR bash -eux" 'sh-base-mode 'bash))
|
||||
|
||||
(ert-deftest files-test-dir-locals-auto-mode-alist ()
|
||||
"Test an `auto-mode-alist' entry in `.dir-locals.el'"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue