Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 1 | vim9script |
| 2 | |
| 3 | # Vim runtime support library |
| 4 | # |
| 5 | # Maintainer: The Vim Project <https://github.com/vim/vim> |
| 6 | # Last Change: 2023 Oct 25 |
| 7 | |
| 8 | export def IsSafeExecutable(filetype: string, executable: string): bool |
Christian Brabandt | 8e25d91 | 2024-08-17 15:52:11 +0200 | [diff] [blame^] | 9 | if empty(exepath(executable)) |
| 10 | echomsg executable .. " not found in $PATH" |
| 11 | return v:false |
| 12 | endif |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 13 | 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 != '.')) |
| 18 | enddef |
| 19 | |
| 20 | # Uncomment this line to check for compilation errors early |
| 21 | # defcompile |