0
0
mirror of https://github.com/vim/vim.git synced 2025-10-07 05:54:16 -04:00

patch 8.2.0930: script filetype detection trips over env -S argument

Problem:    Script filetype detection trips over env -S argument.
Solution:   Remove "-S" and "--ignore-environment". (closes #5013)
            Add tests.
This commit is contained in:
Bram Moolenaar
2020-06-07 21:58:54 +02:00
parent cc613031b9
commit b5e18f29fa
3 changed files with 23 additions and 4 deletions

View File

@@ -607,9 +607,19 @@ let s:script_checks = {
\ 'yaml': [['%YAML 1.2']],
\ }
func Test_script_detection()
" Various forms of "env" optional arguments.
let s:script_env_checks = {
\ 'perl': [['#!/usr/bin/env VAR=val perl']],
\ 'scala': [['#!/usr/bin/env VAR=val VVAR=vval scala']],
\ 'awk': [['#!/usr/bin/env VAR=val -i awk']],
\ 'scheme': [['#!/usr/bin/env VAR=val --ignore-environment scheme']],
\ 'python': [['#!/usr/bin/env VAR=val -S python -w -T']],
\ 'wml': [['#!/usr/bin/env VAR=val --split-string wml']],
\ }
func Run_script_detection(test_dict)
filetype on
for [ft, files] in items(s:script_checks)
for [ft, files] in items(a:test_dict)
for file in files
call writefile(file, 'Xtest')
split Xtest
@@ -621,6 +631,11 @@ func Test_script_detection()
filetype off
endfunc
func Test_script_detection()
call Run_script_detection(s:script_checks)
call Run_script_detection(s:script_env_checks)
endfunc
func Test_setfiletype_completion()
call feedkeys(":setfiletype java\<C-A>\<C-B>\"\<CR>", 'tx')
call assert_equal('"setfiletype java javacc javascript javascriptreact', @:)

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
930,
/**/
929,
/**/