blob: 2277f245330cae1fa893660948afada516899f9d [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))
Christian Brabandt8e25d912024-08-17 15:52:11 +020010 return v:false
11 endif
Christian Brabandt4f174f02023-11-04 11:16:23 +010012 var cwd = getcwd()
13 return get(g:, filetype .. '_exec', get(g:, 'plugin_exec', 0))
14 && (fnamemodify(exepath(executable), ':p:h') !=# cwd
15 || (split($PATH, has('win32') ? ';' : ':')->index(cwd) != -1
16 && cwd != '.'))
17enddef
18
19# Uncomment this line to check for compilation errors early
20# defcompile