aboutsummaryrefslogtreecommitdiff
path: root/test/functional/eval/system_spec.lua
diff options
context:
space:
mode:
authorRui Abreu Ferreira <raf-ep@gmx.com>2017-03-28 16:03:53 +0100
committerJustin M. Keyes <justinkz@gmail.com>2017-04-12 02:10:34 +0200
commitf3cc843755a6d638ada77dc31721aa53b3ff2364 (patch)
treeec2a760337b8d700ae7398feea43230e5b762ca8 /test/functional/eval/system_spec.lua
parent799443c9942fa145320d9cc7c4638bdaa8c8d67a (diff)
downloadrneovim-f3cc843755a6d638ada77dc31721aa53b3ff2364.tar.gz
rneovim-f3cc843755a6d638ada77dc31721aa53b3ff2364.tar.bz2
rneovim-f3cc843755a6d638ada77dc31721aa53b3ff2364.zip
win: libuv_process_spawn(): special-case cmd.exe
Disable CommandLineToArgvW-standard quoting for cmd.exe. libuv assumes spawned processes follow the convention expected by CommandLineToArgvW(). But cmd.exe is non-conformant, so for cmd.exe: - With system([]), the caller has full control (and responsibility) to quote arguments correctly. - With system(''), shell* options are used. libuv quoting is disabled if argv[0] is: - cmd.exe - cmd - $COMSPEC resolving to a path with filename cmd.exe Closes #6329 References #6387
Diffstat (limited to 'test/functional/eval/system_spec.lua')
-rw-r--r--test/functional/eval/system_spec.lua38
1 files changed, 31 insertions, 7 deletions
diff --git a/test/functional/eval/system_spec.lua b/test/functional/eval/system_spec.lua
index 83d8028b56..45ca69707d 100644
--- a/test/functional/eval/system_spec.lua
+++ b/test/functional/eval/system_spec.lua
@@ -129,14 +129,38 @@ describe('system()', function()
screen:detach()
end)
- it('escapes inner double quotes #6329', function()
- if helpers.os_name() == 'windows' then
- -- In Windows cmd.exe's echo prints the quotes
+ if helpers.os_name() == 'windows' then
+ it('with the default cmd.exe shell', function()
eq('""\n', eval([[system('echo ""')]]))
- else
- eq('\n', eval([[system('echo ""')]]))
- end
- end)
+ eq('"a b"\n', eval([[system('echo "a b"')]]))
+ -- TODO: consistent with Vim, but it should be fixed
+ eq('a & echo b\n', eval([[system('echo a & echo b')]]))
+ eval([[system('cd "C:\Program Files"')]])
+ eq(0, eval('v:shell_error'))
+ end)
+
+ it('with set shell="cmd"', function()
+ helpers.source('let &shell="cmd"')
+ eq('"a b"\n', eval([[system('echo "a b"')]]))
+ end)
+
+ it('works with cmd.exe from $COMSPEC', function()
+ local comspecshell = eval("fnamemodify($COMSPEC, ':t')")
+ if comspecshell == 'cmd.exe' then
+ helpers.source('let &shell=$COMSPEC')
+ eq('"a b"\n', eval([[system('echo "a b"')]]))
+ else
+ pending('$COMSPEC is not cmd.exe ' .. comspecshell)
+ end
+ end)
+
+ it('works with powershell', function()
+ helpers.set_shell_powershell()
+ eq('a\nb\n', eval([[system('echo a b')]]))
+ eq('C:\\\n', eval([[system('cd c:\; (Get-Location).Path')]]))
+ eq('a b\n', eval([[system('echo "a b"')]]))
+ end)
+ end
it('`echo` and waits for its return', function()
feed(':call system("echo")<cr>')