From 7360dda670d3702a2f6a8d4b65180a243811695b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Mon, 16 Jan 2023 09:28:40 +0100 Subject: [PATCH] vim-patch:8.2.3071: shell options are not set properly for PowerShell (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) https://github.com/vim/vim/commit/127950241e84c822d3c50f46a00d42a70d2d5cb6 Co-authored-by: Mike Williams --- src/nvim/testdir/test_shell.vim | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/nvim/testdir/test_shell.vim b/src/nvim/testdir/test_shell.vim index e6958a3910..2166308aea 100644 --- a/src/nvim/testdir/test_shell.vim +++ b/src/nvim/testdir/test_shell.vim @@ -24,8 +24,10 @@ func Test_shell_options() if has('win32') let shells += [['cmd', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', ''], \ ['cmd.exe', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '('], - \ ['powershell.exe', '-c', '>', '', '>', '"&|<>()@^', '"'], - \ ['powershell', '-c', '>', '', '>', '"&|<>()@^', '"'], + \ ['powershell.exe', '-Command', '2>&1 | Out-File -Encoding default', + \ '', '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], + \ ['powershell', '-Command', '2>&1 | Out-File -Encoding default', '', + \ '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], \ ['sh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], \ ['ksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], \ ['mksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], @@ -58,6 +60,9 @@ func Test_shell_options() if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$' let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'" let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'" + elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$' + let str1 = "'cmd \"arg1\" ''arg2'' !%#'" + let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\#'" else let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%#'" let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\#'" @@ -136,6 +141,28 @@ func Test_shellescape() let &shell = save_shell endfunc +" Test for 'shellslash' +func Test_shellslash() + CheckOption shellslash + let save_shellslash = &shellslash + " The shell and cmdflag, and expected slash in tempname with shellslash set or + " unset. The assert checks the file separator before the leafname. + " ".*\\\\[^\\\\]*$" + let shells = [['cmd', '/c', '\\', '/'], + \ ['powershell', '-Command', '\\', '/'], + \ ['sh', '-c', '/', '/']] + for e in shells + exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1] + set noshellslash + let file = tempname() + call assert_match('^.\+' .. e[2] .. '[^' .. e[2] .. ']\+$', file, e[0] .. ' ' .. e[1] .. ' nossl') + set shellslash + let file = tempname() + call assert_match('^.\+' .. e[3] .. '[^' .. e[3] .. ']\+$', file, e[0] .. ' ' .. e[1] .. ' ssl') + endfor + let &shellslash = save_shellslash +endfunc + " Test for 'shellxquote' func Test_shellxquote() CheckUnix