mirror of
https://github.com/vim/vim.git
synced 2025-07-04 23:07:33 -04:00
runtime(ftplugin): allow to exec if curdir is in PATH
In case the current directory is present as valid $PATH entry, it is OK to call the program from it, even if vim curdir is in that same directory. (Without that patch, for instance, you will not be able to open .zip files while your current directory is /bin) closes: #13027 Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
9b04c50319
commit
67c951df4c
@ -11,7 +11,10 @@ fun s:check(cmd)
|
|||||||
let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
|
let name = substitute(a:cmd, '\(\S*\).*', '\1', '')
|
||||||
if !exists("s:have_" . name)
|
if !exists("s:have_" . name)
|
||||||
" safety check, don't execute anything from the current directory
|
" safety check, don't execute anything from the current directory
|
||||||
let f = fnamemodify(exepath(name), ":p:h") !=# getcwd()
|
let s:tmp_cwd = getcwd()
|
||||||
|
let f = (fnamemodify(exepath(name), ":p:h") !=# s:tmp_cwd
|
||||||
|
\ || (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) != -1 && s:tmp_cwd != '.'))
|
||||||
|
unlet s:tmp_cwd
|
||||||
if !f
|
if !f
|
||||||
echoerr "Warning: NOT executing " .. name .. " from current directory!"
|
echoerr "Warning: NOT executing " .. name .. " from current directory!"
|
||||||
endif
|
endif
|
||||||
|
@ -57,10 +57,15 @@ if !exists("g:zip_extractcmd")
|
|||||||
let g:zip_extractcmd= g:zip_unzipcmd
|
let g:zip_extractcmd= g:zip_unzipcmd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if fnamemodify(exepath(g:zip_unzipcmd), ":p:h") ==# getcwd()
|
let s:tmp_cwd = getcwd()
|
||||||
|
if (fnamemodify(exepath(g:zip_unzipcmd), ":p:h") ==# getcwd()
|
||||||
|
\ && (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) == -1 || s:tmp_cwd == '.'))
|
||||||
|
unlet s:tmp_cwd
|
||||||
echoerr "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!"
|
echoerr "Warning: NOT executing " .. g:zip_unzipcmd .. " from current directory!"
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
|
unlet s:tmp_cwd
|
||||||
|
|
||||||
" ----------------
|
" ----------------
|
||||||
" Functions: {{{1
|
" Functions: {{{1
|
||||||
" ----------------
|
" ----------------
|
||||||
|
@ -55,7 +55,9 @@ endif
|
|||||||
" Set this once, globally.
|
" Set this once, globally.
|
||||||
if !exists("perlpath")
|
if !exists("perlpath")
|
||||||
" safety check: don't execute perl from current directory
|
" safety check: don't execute perl from current directory
|
||||||
if executable("perl") && fnamemodify(exepath("perl"), ":p:h") != getcwd()
|
let s:tmp_cwd = getcwd()
|
||||||
|
if executable("perl") && (fnamemodify(exepath("perl"), ":p:h") != s:tmp_cwd
|
||||||
|
\ || (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) != -1 && s:tmp_cwd != '.'))
|
||||||
try
|
try
|
||||||
if &shellxquote != '"'
|
if &shellxquote != '"'
|
||||||
let perlpath = system('perl -e "print join(q/,/,@INC)"')
|
let perlpath = system('perl -e "print join(q/,/,@INC)"')
|
||||||
@ -71,6 +73,7 @@ if !exists("perlpath")
|
|||||||
" current directory and the directory of the current file.
|
" current directory and the directory of the current file.
|
||||||
let perlpath = ".,,"
|
let perlpath = ".,,"
|
||||||
endif
|
endif
|
||||||
|
unlet s:tmp_cwd
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" Append perlpath to the existing path value, if it is set. Since we don't
|
" Append perlpath to the existing path value, if it is set. Since we don't
|
||||||
|
@ -77,11 +77,14 @@ function! s:query_path(root) abort
|
|||||||
let cwd = fnameescape(getcwd())
|
let cwd = fnameescape(getcwd())
|
||||||
try
|
try
|
||||||
exe cd fnameescape(a:root)
|
exe cd fnameescape(a:root)
|
||||||
if fnamemodify(exepath('ruby'), ':p:h') ==# cwd
|
let s:tmp_cwd = getcwd()
|
||||||
|
if (fnamemodify(exepath('ruby'), ':p:h') ==# cwd
|
||||||
|
\ && (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) == -1 || s:tmp_cwd == '.'))
|
||||||
let path = []
|
let path = []
|
||||||
else
|
else
|
||||||
let path = split(system(path_check),',')
|
let path = split(system(path_check),',')
|
||||||
endif
|
endif
|
||||||
|
unlet s:tmp_cwd
|
||||||
exe cd cwd
|
exe cd cwd
|
||||||
return path
|
return path
|
||||||
finally
|
finally
|
||||||
|
@ -40,14 +40,17 @@ endif
|
|||||||
let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)'
|
let &l:define='\v(<fn>|<const>|<var>|^\s*\#\s*define)'
|
||||||
|
|
||||||
" Safety check: don't execute zip from current directory
|
" Safety check: don't execute zip from current directory
|
||||||
|
let s:tmp_cwd = getcwd()
|
||||||
if !exists('g:zig_std_dir') && exists('*json_decode') &&
|
if !exists('g:zig_std_dir') && exists('*json_decode') &&
|
||||||
\ executable('zig') && fnamemodify(exepath("zig"), ":p:h") != getcwd()
|
\ executable('zig') && (fnamemodify(exepath("zig"), ":p:h") != s:tmp_cwd
|
||||||
|
\ || (index(split($PATH,has("win32")? ';' : ':'), s:tmp_cwd) != -1 && s:tmp_cwd != '.'))
|
||||||
silent let s:env = system('zig env')
|
silent let s:env = system('zig env')
|
||||||
if v:shell_error == 0
|
if v:shell_error == 0
|
||||||
let g:zig_std_dir = json_decode(s:env)['std_dir']
|
let g:zig_std_dir = json_decode(s:env)['std_dir']
|
||||||
endif
|
endif
|
||||||
unlet! s:env
|
unlet! s:env
|
||||||
endif
|
endif
|
||||||
|
unlet s:tmp_cwd
|
||||||
|
|
||||||
if exists('g:zig_std_dir')
|
if exists('g:zig_std_dir')
|
||||||
let &l:path = &l:path . ',' . g:zig_std_dir
|
let &l:path = &l:path . ',' . g:zig_std_dir
|
||||||
|
Loading…
x
Reference in New Issue
Block a user