summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-06-07 21:58:54 +0200
committerBram Moolenaar <Bram@vim.org>2020-06-07 21:58:54 +0200
commitb5e18f29fac9253b0ccf1fde5e74bff72fa1ba60 (patch)
tree76fd7a1da3baaccd00d4896c08eef49b4b07c0ed /runtime
parentcc613031b96f1cfa5a184253e745c26f1def9be4 (diff)
downloadvim-git-b5e18f29fac9253b0ccf1fde5e74bff72fa1ba60.tar.gz
patch 8.2.0930: script filetype detection trips over env -S argumentv8.2.0930
Problem: Script filetype detection trips over env -S argument. Solution: Remove "-S" and "--ignore-environment". (closes #5013) Add tests.
Diffstat (limited to 'runtime')
-rw-r--r--runtime/scripts.vim6
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/scripts.vim b/runtime/scripts.vim
index ba33f0ebf..6aae2b1ec 100644
--- a/runtime/scripts.vim
+++ b/runtime/scripts.vim
@@ -1,7 +1,7 @@
" Vim support file to detect file types in scripts
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last change: 2020 Mar 06
+" Last change: 2020 Jun 07
" This file is called by an autocommand for every file that has just been
" loaded into a buffer. It checks if the type of file can be recognized by
@@ -35,10 +35,12 @@ let s:line1 = getline(1)
if s:line1 =~# "^#!"
" A script that starts with "#!".
- " Check for a line like "#!/usr/bin/env VAR=val bash". Turn it into
+ " Check for a line like "#!/usr/bin/env {options} bash". Turn it into
" "#!/usr/bin/bash" to make matching easier.
+ " Recognize only a few {options} that are commonly used.
if s:line1 =~# '^#!\s*\S*\<env\s'
let s:line1 = substitute(s:line1, '\S\+=\S\+', '', 'g')
+ let s:line1 = substitute(s:line1, '\(-[iS]\|--ignore-environment\|--split-string\)', '', '')
let s:line1 = substitute(s:line1, '\<env\s\+', '', '')
endif