-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
fix(windows): treat powershell as not-Unix-like in Windows #21175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bb65cc7
to
49f9cb1
Compare
49f9cb1
to
25bba25
Compare
cc @3N4N |
Do we not want extensionless files to be found with 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. But both But neovim with ':set shell=cmd', doesn't find 'test' either (without applying this patch), even though Edit: |
So, as I understand it, if |
Right. As it stands now, exepath in this PR behaves correctly. |
8c55d9b
to
a7d6602
Compare
Would it be a good idea if |
in Git bash on windows, files without ".exe" suffix can be executable, right?
Great info, thanks! So what is the 3-line conclusion here? Please include it in the commit message. |
Not completely sure of the specs, but I think only script (bash, sh, etc.) executables can have no extension in Git Bash. Binary executables require |
This comment was marked as resolved.
This comment was marked as resolved.
a7d6602
to
6f9c138
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
Oh, yeah I misunderstood that 😅 |
6f9c138
to
5f927aa
Compare
ported vim-patch 8.2.3071 and related patches to avoid needing to revisit this in the future. 8.2.3071 is mostly N/A because all the magic special-case bullshit (changing slash behavior depending on shell, changing option defaults depending on x, y, z and bloating the docs) is not something we want. I was hoping 8.2.3071 added test coverage for what this PR fixes, but doesn't look like it. We need a test case in |
Some other related patches: #19313 |
c199a69
to
5faec60
Compare
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 neovim#21045
… out Problem: Testing the shell option is incomplete and spread out. Solution: Move shell tests to one file and increase coverage. (Yegappan Lakshmanan, closes vim/vim#8464) vim/vim@054794c Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Not enough testing for shell use. Solution: Add a bit more testing. (Yegappan Lakshmanan, closes vim/vim#8469) vim/vim@ffec6dd Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
(Most of this patch is intentionally dropped, it adds far too much special-cases for almost zero purpose: ":help shell-powershell" makes it easy to choose powershell without spreading special-cases throughout the codebase, randomly changing slash behavior, etc.) Problem: Shell options are not set properly for PowerShell. Solution: Use better option defaults. (Mike Willams, closes vim/vim#8459) vim/vim@1279502 Co-authored-by: Mike Williams <mikew@globalgraphics.com>
'shellxquote' Nvim default was adjusted in: 131aad9 The use of "/s" is different than Vim, and may avoid the need for `shellxquote="&|<>()@^`. For the other shells, Nvim intentionally does not fiddle with the various "shell*" options if 'shell' is set by the user: if the user sets 'shell', they are expected to set other "shell*" options correctly.
5faec60
to
e5b9485
Compare
Merged to unblock, but it would still be helpful to have this test @akriese |
windows shells This test covers the changes from neovim#21175 where exepath() is set to prefer file extensions in powershell.exe aswell as in cmd.exe. In both shells, the file with a valid extension should be returned instead of the extensionless file.
I just created this test. First time writing a test for neovim, so forgive me, if I did something wrong. Unfortunately, I don't know how to run the test on Windows with Edit: Also, the test for |
I suggest using cmake for everything. Neovim is a cmake project; the makefile provided with it is only for convenience, and I don't think it's catered too much to Windows devs. What I do is use something like these:
I'm not gonna explain what's happening in the commands above. You should be able to figure out with a little bit of time.
There is a helper function in the test suite called |
Also, @akriese you should do this in a new PR. |
Windows shells This test covers the changes from neovim#21175 where exepath() is set to prefer file extensions in powershell.exe aswell as in cmd.exe. In both shells, the file with a valid extension should be returned instead of the extensionless file.
Windows shells This test covers the changes from neovim#21175 where exepath() is set to prefer file extensions in powershell.exe aswell as in cmd.exe. In both shells, the file with a valid extension should be returned instead of the extensionless file.
see also https://github.com/neovim/neovim/wiki/Building-Neovim#windows--msvc-powershell (@3N4N any improvements to make there?) |
I used the instructions in the README aswell as @3N4N's commands. Didn't work out of the box, maybe my environment has some issue. It eventually worked out for me when explicitly passing the |
Windows shells This test covers the changes from neovim#21175 where exepath() is set to prefer file extensions in powershell.exe aswell as in cmd.exe. In both shells, the file with a valid extension should be returned instead of the extensionless file.
Windows shells This test covers the changes from neovim#21175 where exepath() is set to prefer file extensions in powershell.exe aswell as in cmd.exe. In both shells, the file with a valid extension should be returned instead of the extensionless file.
test(exepath): test if exepath returns correct path with multiple Windows shells This test covers the changes from #21175 where exepath() is set to prefer file extensions in powershell.exe aswell as in cmd.exe. In both shells, the file with a valid extension should be returned instead of the extensionless file.
…21928 test(exepath): test if exepath returns correct path with multiple Windows shells This test covers the changes from neovim#21175 where exepath() is set to prefer file extensions in powershell.exe aswell as in cmd.exe. In both shells, the file with a valid extension should be returned instead of the extensionless file.
Fixes #21045.
This takes part of vim patch v8.2.3071 to make
pwsh
andpowershell
return the sameexepath()
s (including extensions) ascmd.exe
.