forked from aniani/vim
Otherwise, if the executable to be verified does not exist, this would cause a false-positive in the 'IsSafeExecutable()' check, because 'exepath(executable)' returns an empty string and 'fnamemodify('', ':p:h')' returns the current directory and as a result the 'IsSafeExecutable()' returns false (for the wrong reason). Signed-off-by: Christian Brabandt <cb@256bit.org>
22 lines
649 B
VimL
22 lines
649 B
VimL
vim9script
|
|
|
|
# Vim runtime support library
|
|
#
|
|
# Maintainer: The Vim Project <https://github.com/vim/vim>
|
|
# Last Change: 2023 Oct 25
|
|
|
|
export def IsSafeExecutable(filetype: string, executable: string): bool
|
|
if empty(exepath(executable))
|
|
echomsg executable .. " not found in $PATH"
|
|
return v:false
|
|
endif
|
|
var cwd = getcwd()
|
|
return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
|
|
&& (fnamemodify(exepath(executable), ':p:h') !=# cwd
|
|
|| (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1
|
|
&& cwd != '.'))
|
|
enddef
|
|
|
|
# Uncomment this line to check for compilation errors early
|
|
# defcompile
|