mirror of
https://github.com/neovim/neovim.git
synced 2025-11-03 09:14:24 +00:00
fix: make_filter_cmd for :! powershell
Problem: `Start-Process` requires the command to be split into the shell command and its arguments. Previously it was done by parsing, which didn't handle cases such as - commands with escaped space in their filepath - quoted commands with space in their filepath Solution: Use - `pwsh -Command` instead of `Start-Process` - `Get-Content` instead of `-RedirectStandardInput` - `Out-File` instead of `-RedirectStandardOutput`
This commit is contained in:
@@ -562,16 +562,16 @@ function module.set_shell_powershell(fake)
|
||||
assert(found)
|
||||
end
|
||||
local shell = found and (iswin() and 'powershell' or 'pwsh') or module.testprg('pwsh-test')
|
||||
local set_encoding = '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.Encoding]::UTF8;'
|
||||
local set_encoding = '[Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();'
|
||||
local cmd = set_encoding..'Remove-Item -Force '..table.concat(iswin()
|
||||
and {'alias:cat', 'alias:echo', 'alias:sleep'}
|
||||
and {'alias:cat', 'alias:echo', 'alias:sleep', 'alias:sort'}
|
||||
or {'alias:echo'}, ',')..';'
|
||||
module.exec([[
|
||||
let &shell = ']]..shell..[['
|
||||
set shellquote= shellxquote=
|
||||
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ]]..cmd..[['
|
||||
let &shellpipe = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
|
||||
let &shellredir = '-RedirectStandardOutput %s -NoNewWindow -Wait'
|
||||
let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s; exit $LastExitCode'
|
||||
]])
|
||||
return found
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user