diff options
| author | Kévin Le Gouguec | 2024-02-10 17:56:57 +0100 |
|---|---|---|
| committer | Eli Zaretskii | 2024-02-17 10:31:47 +0200 |
| commit | c64e650fb346d92294703d22f8cd7deb7c47b49e (patch) | |
| tree | bfe1f04bdbf67a87c4465cb4f34eb4be87dcc5cd | |
| parent | ecb9641ecb5f42899042ff9c164ec7dbb8e166fe (diff) | |
| download | emacs-c64e650fb346d92294703d22f8cd7deb7c47b49e.tar.gz emacs-c64e650fb346d92294703d22f8cd7deb7c47b49e.zip | |
Support shebang lines with amended environment
For bug#64939.
* lisp/files.el (auto-mode-interpreter-regexp): Account for possible
VARIABLE=[VALUE] operands.
* test/lisp/files-tests.el (files-tests-auto-mode-interpreter):
Add an example from the coreutils manual.
| -rw-r--r-- | lisp/files.el | 5 | ||||
| -rw-r--r-- | test/lisp/files-tests.el | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lisp/files.el b/lisp/files.el index 5098d49048e..524385edc84 100644 --- a/lisp/files.el +++ b/lisp/files.el | |||
| @@ -3274,12 +3274,15 @@ and `inhibit-local-variables-suffixes'. If | |||
| 3274 | ;; Optional group 1: env(1) invocation. | 3274 | ;; Optional group 1: env(1) invocation. |
| 3275 | "\\(" | 3275 | "\\(" |
| 3276 | "[^ \t\n]*/bin/env[ \t]*" | 3276 | "[^ \t\n]*/bin/env[ \t]*" |
| 3277 | ;; Within group 1: possible -S/--split-string. | 3277 | ;; Within group 1: possible -S/--split-string and environment |
| 3278 | ;; adjustments. | ||
| 3278 | "\\(?:" | 3279 | "\\(?:" |
| 3279 | ;; -S/--split-string | 3280 | ;; -S/--split-string |
| 3280 | "\\(?:-[0a-z]*S[ \t]*\\|--split-string=\\)" | 3281 | "\\(?:-[0a-z]*S[ \t]*\\|--split-string=\\)" |
| 3281 | ;; More env arguments. | 3282 | ;; More env arguments. |
| 3282 | "\\(?:-[^ \t\n]+[ \t]+\\)*" | 3283 | "\\(?:-[^ \t\n]+[ \t]+\\)*" |
| 3284 | ;; Interpreter environment modifications. | ||
| 3285 | "\\(?:[^ \t\n]+=[^ \t\n]*[ \t]+\\)*" | ||
| 3283 | "\\)?" | 3286 | "\\)?" |
| 3284 | "\\)?" | 3287 | "\\)?" |
| 3285 | ;; Group 2: interpreter. | 3288 | ;; Group 2: interpreter. |
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 0a5c3b897e4..d4c1ef3ba67 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el | |||
| @@ -1694,7 +1694,9 @@ set to." | |||
| 1694 | (files-tests--check-shebang "#!/usr/bin/env -S-vi bash -eux" 'sh-base-mode 'bash) | 1694 | (files-tests--check-shebang "#!/usr/bin/env -S-vi bash -eux" 'sh-base-mode 'bash) |
| 1695 | (files-tests--check-shebang "#!/usr/bin/env -ivS --default-signal=INT bash -eux" 'sh-base-mode 'bash) | 1695 | (files-tests--check-shebang "#!/usr/bin/env -ivS --default-signal=INT bash -eux" 'sh-base-mode 'bash) |
| 1696 | (files-tests--check-shebang "#!/usr/bin/env -ivS --default-signal bash -eux" 'sh-base-mode 'bash) | 1696 | (files-tests--check-shebang "#!/usr/bin/env -ivS --default-signal bash -eux" 'sh-base-mode 'bash) |
| 1697 | (files-tests--check-shebang "#!/usr/bin/env -vS -uFOOBAR bash -eux" 'sh-base-mode 'bash)) | 1697 | (files-tests--check-shebang "#!/usr/bin/env -vS -uFOOBAR bash -eux" 'sh-base-mode 'bash) |
| 1698 | ;; Invocation through env, with modified environment. | ||
| 1699 | (files-tests--check-shebang "#!/usr/bin/env -S PYTHONPATH=/...:${PYTHONPATH} python" 'python-base-mode)) | ||
| 1698 | 1700 | ||
| 1699 | (ert-deftest files-test-dir-locals-auto-mode-alist () | 1701 | (ert-deftest files-test-dir-locals-auto-mode-alist () |
| 1700 | "Test an `auto-mode-alist' entry in `.dir-locals.el'" | 1702 | "Test an `auto-mode-alist' entry in `.dir-locals.el'" |