Mercurial > vim
comparison src/testdir/test_shell.vim @ 25084:beff72446e2e v8.2.3079
patch 8.2.3079: Powershell core not supported by default
Commit: https://github.com/vim/vim/commit/a3d1b29bd36487167c98b3cefa30f06c529e412d
Author: Mike Williams <mikew@globalgraphics.com>
Date: Wed Jun 30 20:56:00 2021 +0200
patch 8.2.3079: Powershell core not supported by default
Problem: Powershell core not supported by default.
Solution: Set option defaults for "pwsh". (Mike Williams, closes https://github.com/vim/vim/issues/8481)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 30 Jun 2021 21:00:05 +0200 |
parents | 0ce24f734615 |
children | d5e9c05b4811 |
comparison
equal
deleted
inserted
replaced
25083:05c4686c56d2 | 25084:beff72446e2e |
---|---|
17 \ ['bash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], | 17 \ ['bash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
18 \ ['fish', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], | 18 \ ['fish', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
19 \ ['ash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], | 19 \ ['ash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
20 \ ['dash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], | 20 \ ['dash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
21 \ ['csh', '-c', '|& tee', '', '>&', '', ''], | 21 \ ['csh', '-c', '|& tee', '', '>&', '', ''], |
22 \ ['tcsh', '-c', '|& tee', '', '>&', '', '']] | 22 \ ['tcsh', '-c', '|& tee', '', '>&', '', ''], |
23 \ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '', '']] | |
23 endif | 24 endif |
24 if has('win32') | 25 if has('win32') |
25 let shells += [['cmd', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', ''], | 26 let shells += [['cmd', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', ''], |
26 \ ['cmd.exe', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '('], | 27 \ ['cmd.exe', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '('], |
27 \ ['powershell.exe', '-Command', '2>&1 | Out-File -Encoding default', | 28 \ ['powershell.exe', '-Command', '2>&1 | Out-File -Encoding default', |
28 \ '', '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], | 29 \ '', '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], |
29 \ ['powershell', '-Command', '2>&1 | Out-File -Encoding default', '', | 30 \ ['powershell', '-Command', '2>&1 | Out-File -Encoding default', '', |
30 \ '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], | 31 \ '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], |
32 \ ['pwsh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], | |
33 \ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], | |
31 \ ['sh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], | 34 \ ['sh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
32 \ ['ksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], | 35 \ ['ksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
33 \ ['mksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], | 36 \ ['mksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
34 \ ['pdksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], | 37 \ ['pdksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
35 \ ['zsh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], | 38 \ ['zsh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
59 exe 'set shell=' .. e[0] | 62 exe 'set shell=' .. e[0] |
60 if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$' | 63 if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$' |
61 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'" | 64 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'" |
62 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'" | 65 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'" |
63 elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$' | 66 elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$' |
67 \ || e[0] =~# '.*pwsh$' || e[0] =~# '.*pwsh.exe$' | |
64 let str1 = "'cmd \"arg1\" ''arg2'' !%#'" | 68 let str1 = "'cmd \"arg1\" ''arg2'' !%#'" |
65 let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\#'" | 69 let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\#'" |
66 else | 70 else |
67 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%#'" | 71 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%#'" |
68 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\#'" | 72 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\#'" |
74 if executable(e[0]) | 78 if executable(e[0]) |
75 " set the shell options for the current 'shell' | 79 " set the shell options for the current 'shell' |
76 let [&shellcmdflag, &shellpipe, &shellquote, &shellredir, | 80 let [&shellcmdflag, &shellpipe, &shellquote, &shellredir, |
77 \ &shellxescape, &shellxquote] = e[1:6] | 81 \ &shellxescape, &shellxquote] = e[1:6] |
78 new | 82 new |
79 r !echo hello | 83 try |
80 call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0]) | 84 r !echo hello |
81 bwipe! | 85 call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0]) |
86 catch | |
87 call assert_report('Failed to run shell command, shell: ' .. e[0]) | |
88 finally | |
89 bwipe! | |
90 endtry | |
82 endif | 91 endif |
83 endfor | 92 endfor |
84 set shell& shellcmdflag& shellpipe& shellquote& | 93 set shell& shellcmdflag& shellpipe& shellquote& |
85 set shellredir& shellxescape& shellxquote& | 94 set shellredir& shellxescape& shellxquote& |
86 call delete('Xtestout') | 95 call delete('Xtestout') |
147 " The shell and cmdflag, and expected slash in tempname with shellslash set or | 156 " The shell and cmdflag, and expected slash in tempname with shellslash set or |
148 " unset. The assert checks the file separator before the leafname. | 157 " unset. The assert checks the file separator before the leafname. |
149 " ".*\\\\[^\\\\]*$" | 158 " ".*\\\\[^\\\\]*$" |
150 let shells = [['cmd', '/c', '\\', '/'], | 159 let shells = [['cmd', '/c', '\\', '/'], |
151 \ ['powershell', '-Command', '\\', '/'], | 160 \ ['powershell', '-Command', '\\', '/'], |
161 \ ['pwsh', '-Command', '\\', '/'], | |
162 \ ['pwsh', '-c', '\\', '/'], | |
152 \ ['sh', '-c', '/', '/']] | 163 \ ['sh', '-c', '/', '/']] |
153 for e in shells | 164 for e in shells |
154 exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1] | 165 exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1] |
155 set noshellslash | 166 set noshellslash |
156 let file = tempname() | 167 let file = tempname() |