|| fnamecmp(shell_name, "powershell.exe") == 0
|| fnamecmp(shell_name, "pwsh") == 0
|| fnamecmp(shell_name, "pwsh.exe") == 0);
- len = (long_u)STRLEN(cmd) + 3; // "()" + NUL
+ if (is_powershell)
+ len = (long_u)STRLEN(cmd) + 7; // "& { " + " }" + NUL
+ else
+ len = (long_u)STRLEN(cmd) + 3; // "()" + NUL
}
if (itmp != NULL)
{
if (is_powershell)
- // "& { Get-Content " + " | & " + " }"
- len += (long_u)STRLEN(itmp) + 24;
+ // "Get-Content " + " | & "
+ len += (long_u)STRLEN(itmp) + 17;
else
len += (long_u)STRLEN(itmp) + 9; // " { < " + " } "
}
vim_snprintf((char *)buf, len, "& { Get-Content %s | & %s }",
itmp, cmd);
else
- vim_snprintf((char *)buf, len, "(%s)", cmd);
+ vim_snprintf((char *)buf, len, "& { %s }", cmd);
}
else
{
set guioptions&
endfunc
+func Test_system_with_powershell()
+ CheckPowerShell
+
+ let shell_save = &shell
+ let shellcmdflag_save = &shellcmdflag
+ let shellxquote_save = &shellxquote
+ let shellpipe_save = &shellpipe
+ let shellredir_save = &shellredir
+ try
+ if executable('powershell')
+ let &shell = 'powershell'
+ let &shellcmdflag = '-Command'
+ let &shellredir = '2>&1 | Out-File -Encoding default'
+ else
+ let &shell = 'pwsh'
+ let &shellcmdflag = '-c'
+ let &shellredir = '>%s 2>&1'
+ endif
+ let &shellxquote = has('win32') ? '"' : ''
+ let &shellpipe = &shellredir
+
+ " Make sure compound commands are handled properly.
+ call assert_equal("123\n456\n", system('echo 123; echo 456'))
+ finally
+ let &shell = shell_save
+ let &shellcmdflag = shellcmdflag_save
+ let &shellxquote = shellxquote_save
+ let &shellpipe = shellpipe_save
+ let &shellredir = shellredir_save
+ endtry
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
endif
endfunc
+" Command to check whether PowerShell is available
+command CheckPowerShell call CheckPowerShell()
+func CheckPowerShell()
+ if !executable('powershell') && !executable('pwsh')
+ throw 'Skipped: requires Powershell to be installed'
+ endif
+endfunc
+
func SetupWindowSizeToForVisualDumps()
" The dumps used as reference in these tests were created with a terminal
" width of 75 columns. The vim window that uses the remainder of the GUI
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 6,
/**/
5,
/**/