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)) |
Christian Brabandt | 8e25d91 | 2024-08-17 15:52:11 +0200 | [diff] [blame] | 10 | return v:false |
| 11 | endif |
Christian Brabandt | 4f174f0 | 2023-11-04 11:16:23 +0100 | [diff] [blame] | 12 | 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 != '.')) |
| 17 | enddef |
| 18 | |
| 19 | # Uncomment this line to check for compilation errors early |
| 20 | # defcompile |