blob: 8fa9380f5774f53838ced5266c6561f73a6bdad5 [file] [log] [blame]
Christian Brabandt4f174f02023-11-04 11:16:23 +01001vim9script
2
3# Vim runtime support library
4#
5# Maintainer: The Vim Project <https://github.com/vim/vim>
6# Last Change: 2023 Oct 25
7
8export def IsSafeExecutable(filetype: string, executable: string): bool
Christian Brabandt8e25d912024-08-17 15:52:11 +02009 if empty(exepath(executable))
10 echomsg executable .. " not found in $PATH"
11 return v:false
12 endif
Christian Brabandt4f174f02023-11-04 11:16:23 +010013 var cwd = getcwd()
14 return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
15 && (fnamemodify(exepath(executable), ':p:h') !=# cwd
16 || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1
17 && cwd != '.'))
18enddef
19
20# Uncomment this line to check for compilation errors early
21# defcompile