0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.0850: MS-Windows: exepath() works different from cmd.exe

Problem:    MS-Windows: exepath() works different from cmd.exe.
Solution:   Make exepath() work better on MS-Windows. (closes #6115)
This commit is contained in:
Bram Moolenaar
2020-05-30 18:37:55 +02:00
parent 041c7107f2
commit 95da136142
4 changed files with 213 additions and 106 deletions

View File

@@ -1187,6 +1187,30 @@ func Test_Executable()
call assert_equal(0, executable('notepad.exe.exe'))
call assert_equal(0, executable('shell32.dll'))
call assert_equal(0, executable('win.ini'))
" get "notepad" path and remove the leading drive and sep. (ex. 'C:\')
let notepadcmd = exepath('notepad.exe')
let driveroot = notepadcmd[:2]
let notepadcmd = notepadcmd[3:]
new
" check that the relative path works in /
execute 'lcd' driveroot
call assert_equal(1, executable(notepadcmd))
call assert_equal(driveroot .. notepadcmd, notepadcmd->exepath())
bwipe
" create "notepad.bat"
call mkdir('Xdir')
let notepadbat = fnamemodify('Xdir/notepad.bat', ':p')
call writefile([], notepadbat)
new
" check that the path and the pathext order is valid
lcd Xdir
let [pathext, $PATHEXT] = [$PATHEXT, '.com;.exe;.bat;.cmd']
call assert_equal(notepadbat, exepath('notepad'))
let $PATHEXT = pathext
bwipe
eval 'Xdir'->delete('rf')
elseif has('unix')
call assert_equal(1, 'cat'->executable())
call assert_equal(0, executable('nodogshere'))