Skip to content

Instantly share code, notes, and snippets.

@equalsraf
Last active February 2, 2017 22:58
Show Gist options
  • Save equalsraf/774c1405feaaf1c8eaf48bca90bccf81 to your computer and use it in GitHub Desktop.
Save equalsraf/774c1405feaaf1c8eaf48bca90bccf81 to your computer and use it in GitHub Desktop.

executable()

os_can_exe() used by executable() actually checks PATHEXT. Behaviour in Vim is:

executable('no_such_file') returns 0
executable('file') returns 1 if file.bat,file.exe,etc exist ($PATHEXT)
executable('file.bat')returns 1
executable('file.exe')returns 1

This could lead to the misconception that, for example, executable("file.bat") being 1 implies that system(["file.bat"]) is expected to succeed, which is not true. But this is an issue with system([]) in windows and not with executable(). The notion of executable in Windows is fundamentaly a shell concept, because unlike UNIX there no notion of shebang and permission bits, that allows execution of non binary files.

$PATHEXT

The original behaviour in Vim and I believe its still the case in Neovim, is that if $PATHEXT is missing a default of .com;.exe;.bat;.cmd is used.

@justinmk
Copy link

justinmk commented Feb 1, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment