doc: update shellquote for powershell #11122
shellquote is not treated like shellxquote for non-quote values.
This commit is contained in:
parent
f2ad93168b
commit
51f2826f61
|
@ -5169,7 +5169,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
||||||
unescaping, so to keep yourself sane use |:let-&| like shown above.
|
unescaping, so to keep yourself sane use |:let-&| like shown above.
|
||||||
*shell-powershell*
|
*shell-powershell*
|
||||||
To use powershell (on Windows): >
|
To use powershell (on Windows): >
|
||||||
set shell=powershell shellquote=( shellpipe=\| shellxquote=
|
set shell=powershell shellquote= shellpipe=\| shellxquote=
|
||||||
set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command
|
set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command
|
||||||
set shellredir=\|\ Out-File\ -Encoding\ UTF8
|
set shellredir=\|\ Out-File\ -Encoding\ UTF8
|
||||||
|
|
||||||
|
|
|
@ -501,9 +501,20 @@ function module.source(code)
|
||||||
end
|
end
|
||||||
|
|
||||||
function module.set_shell_powershell()
|
function module.set_shell_powershell()
|
||||||
|
local shell = iswin() and 'powershell' or 'pwsh'
|
||||||
|
if not module.eval('executable("'..shell..'")') then
|
||||||
|
error(shell..' is not executable')
|
||||||
|
end
|
||||||
|
local aliases = iswin() and {'cat', 'sleep'} or {}
|
||||||
|
local cmd = ''
|
||||||
|
for _, alias in ipairs(aliases) do
|
||||||
|
cmd = cmd .. 'Remove-Item -Force alias:' .. alias .. ';'
|
||||||
|
end
|
||||||
module.source([[
|
module.source([[
|
||||||
set shell=powershell shellquote=( shellpipe=\| shellredir=> shellxquote=
|
let &shell = ']]..shell..[['
|
||||||
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command Remove-Item -Force alias:sleep; Remove-Item -Force alias:cat;'
|
set shellquote= shellpipe=\| shellxquote=
|
||||||
|
let &shellredir = '| Out-File -Encoding UTF8'
|
||||||
|
let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command ]]..cmd..[['
|
||||||
]])
|
]])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ local iswin = helpers.iswin
|
||||||
local clear = helpers.clear
|
local clear = helpers.clear
|
||||||
local command = helpers.command
|
local command = helpers.command
|
||||||
local nvim_dir = helpers.nvim_dir
|
local nvim_dir = helpers.nvim_dir
|
||||||
|
local set_shell_powershell = helpers.set_shell_powershell
|
||||||
|
|
||||||
describe("shell command :!", function()
|
describe("shell command :!", function()
|
||||||
local screen
|
local screen
|
||||||
|
@ -230,4 +231,19 @@ describe("shell command :!", function()
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
if iswin() or eval('executable("pwsh")') == 1 then
|
||||||
|
it('powershell supports literal strings', function()
|
||||||
|
set_shell_powershell()
|
||||||
|
local screen = Screen.new(30, 4)
|
||||||
|
screen:attach()
|
||||||
|
feed_command([[!'echo $a']])
|
||||||
|
screen:expect{any='\necho %$a', timeout=10000}
|
||||||
|
feed_command([[!$a = 1; echo '$a']])
|
||||||
|
screen:expect{any='\n%$a', timeout=10000}
|
||||||
|
feed_command([[!"echo $a"]])
|
||||||
|
screen:expect{any='\necho', timeout=10000}
|
||||||
|
feed_command([[!$a = 1; echo "$a"]])
|
||||||
|
screen:expect{any='\n1', timeout=10000}
|
||||||
|
end)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue