comparison runtime/scripts.vim @ 20756:33a14786a0e4 v8.2.0930

patch 8.2.0930: script filetype detection trips over env -S argument Commit: https://github.com/vim/vim/commit/b5e18f29fac9253b0ccf1fde5e74bff72fa1ba60 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 7 21:58:54 2020 +0200 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 https://github.com/vim/vim/issues/5013) Add tests.
author Bram Moolenaar <Bram@vim.org>
date Sun, 07 Jun 2020 22:00:04 +0200
parents 847a300aa244
children 0db0640e16e0
comparison
equal deleted inserted replaced
20755:c3f999111bfd 20756:33a14786a0e4
1 " Vim support file to detect file types in scripts 1 " Vim support file to detect file types in scripts
2 " 2 "
3 " Maintainer: Bram Moolenaar <Bram@vim.org> 3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last change: 2020 Mar 06 4 " Last change: 2020 Jun 07
5 5
6 " This file is called by an autocommand for every file that has just been 6 " This file is called by an autocommand for every file that has just been
7 " loaded into a buffer. It checks if the type of file can be recognized by 7 " loaded into a buffer. It checks if the type of file can be recognized by
8 " the file contents. The autocommand is in $VIMRUNTIME/filetype.vim. 8 " the file contents. The autocommand is in $VIMRUNTIME/filetype.vim.
9 " 9 "
33 let s:line1 = getline(1) 33 let s:line1 = getline(1)
34 34
35 if s:line1 =~# "^#!" 35 if s:line1 =~# "^#!"
36 " A script that starts with "#!". 36 " A script that starts with "#!".
37 37
38 " Check for a line like "#!/usr/bin/env VAR=val bash". Turn it into 38 " Check for a line like "#!/usr/bin/env {options} bash". Turn it into
39 " "#!/usr/bin/bash" to make matching easier. 39 " "#!/usr/bin/bash" to make matching easier.
40 " Recognize only a few {options} that are commonly used.
40 if s:line1 =~# '^#!\s*\S*\<env\s' 41 if s:line1 =~# '^#!\s*\S*\<env\s'
41 let s:line1 = substitute(s:line1, '\S\+=\S\+', '', 'g') 42 let s:line1 = substitute(s:line1, '\S\+=\S\+', '', 'g')
43 let s:line1 = substitute(s:line1, '\(-[iS]\|--ignore-environment\|--split-string\)', '', '')
42 let s:line1 = substitute(s:line1, '\<env\s\+', '', '') 44 let s:line1 = substitute(s:line1, '\<env\s\+', '', '')
43 endif 45 endif
44 46
45 " Get the program name. 47 " Get the program name.
46 " Only accept spaces in PC style paths: "#!c:/program files/perl [args]". 48 " Only accept spaces in PC style paths: "#!c:/program files/perl [args]".