mirror of
https://github.com/neovim/neovim.git
synced 2026-07-15 05:40:34 +00:00
fix(exepath)!: prefers extensionless for powershell
PROBLEM:
exepath("test") should prefer ".bat" when shell=powershell.
Current behavior differs from Vim 8.2.3071.
TEST CASE:
1. in a folder which is in $PATH, create files "test" "test.bat".
- "(Get-Command test).Path test" returns "test.bat".
2. compare nvim:
nvim --clean
:set shell=powershell
:echo exepath("test")
3. should returns "path\to\test.bat" (before this patch it returns "path\to\test").
SOLUTION:
After this patch, the binary files "text.exe", "test.bat", "test.com"
will be found, but the file "test" (without any extension) will not be
found (matches Vim 8.2.3071). But powershell's `where` and
`Get-Command` _do_ find the extensionless 'test' file.
But Nvim with ":set shell=cmd.exe", doesn't find "test" either (before
and after this patch), even though `where test` returns correct path in
cmd.
- `where` is a program to find files in general, not just executable files.
-`Get-Command` returning extensionless (and thus non-executable) file is
puzzling even to Chris Dent, [PowerShell expert][1] (asked on
Discord).
[1]: https://www.amazon.com/Mastering-PowerShell-Scripting-Automate-environment-ebook/dp/B0971MG88X
Co-authored-by: Enan Ajmain <3nan.ajmain@gmail.com>
Helped-by: erw7 <erw7.github@gmail.com>
Fixes #21045
This commit is contained in:
committed by
Justin M. Keyes
parent
34b973b1d9
commit
52268afb1c
@@ -302,7 +302,9 @@ static bool is_executable(const char *name, char **abspath)
|
||||
static bool is_executable_ext(const char *name, char **abspath)
|
||||
FUNC_ATTR_NONNULL_ARG(1)
|
||||
{
|
||||
const bool is_unix_shell = strstr((char *)path_tail(p_sh), "sh") != NULL;
|
||||
const bool is_unix_shell = strstr(path_tail(p_sh), "powershell") == NULL
|
||||
&& strstr(path_tail(p_sh), "pwsh") == NULL
|
||||
&& strstr(path_tail(p_sh), "sh") != NULL;
|
||||
char *nameext = strrchr(name, '.');
|
||||
size_t nameext_len = nameext ? strlen(nameext) : 0;
|
||||
xstrlcpy(os_buf, name, sizeof(os_buf));
|
||||
|
||||
Reference in New Issue
Block a user