mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
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 #8481)
This commit is contained in:
committed by
Bram Moolenaar
parent
834193afd7
commit
a3d1b29bd3
@@ -9878,11 +9878,13 @@ sha256({string}) *sha256()*
|
|||||||
|
|
||||||
shellescape({string} [, {special}]) *shellescape()*
|
shellescape({string} [, {special}]) *shellescape()*
|
||||||
Escape {string} for use as a shell command argument.
|
Escape {string} for use as a shell command argument.
|
||||||
On MS-Windows, when the 'shell' contains powershell then it
|
When the 'shell' contains powershell (MS-Windows) or pwsh
|
||||||
will enclose {string} in single quotes and will double up all
|
(MS-Windows, Linux, and MacOS) then it will enclose {string}
|
||||||
internal single quotes. With other values for 'shell' when
|
in single quotes and will double up all internal single
|
||||||
'shellslash' is not set, it will enclose {string} in double
|
quotes.
|
||||||
quotes and double all double quotes within {string}.
|
On MS-Windows, when 'shellslash' is not set, it will enclose
|
||||||
|
{string} in double quotes and double all double quotes within
|
||||||
|
{string}.
|
||||||
Otherwise it will enclose {string} in single quotes and
|
Otherwise it will enclose {string} in single quotes and
|
||||||
replace all "'" with "'\''".
|
replace all "'" with "'\''".
|
||||||
|
|
||||||
@@ -11042,8 +11044,8 @@ tempname() *tempname()* *temp-file-name*
|
|||||||
:exe "redir > " . tmpfile
|
:exe "redir > " . tmpfile
|
||||||
< For Unix, the file will be in a private directory |tempfile|.
|
< For Unix, the file will be in a private directory |tempfile|.
|
||||||
For MS-Windows forward slashes are used when the 'shellslash'
|
For MS-Windows forward slashes are used when the 'shellslash'
|
||||||
option is set or when 'shellcmdflag' starts with '-' except
|
option is set, or when 'shellcmdflag' starts with '-' and
|
||||||
when when 'shell' contains powershell.
|
'shell' does not contain powershell or pwsh.
|
||||||
|
|
||||||
|
|
||||||
term_ functions are documented here: |terminal-function-details|
|
term_ functions are documented here: |terminal-function-details|
|
||||||
|
@@ -6633,6 +6633,8 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
"bash", "fish", "ash" or "dash" the default becomes "2>&1| tee". This
|
"bash", "fish", "ash" or "dash" the default becomes "2>&1| tee". This
|
||||||
means that stderr is also included. Before using the 'shell' option a
|
means that stderr is also included. Before using the 'shell' option a
|
||||||
path is removed, thus "/bin/sh" uses "sh".
|
path is removed, thus "/bin/sh" uses "sh".
|
||||||
|
For Unix and MS-Windows, when the 'shell' option is "pwsh" the default
|
||||||
|
becomes ">%s 2>&1" and the output is not echoed to the screen.
|
||||||
The initialization of this option is done after reading the ".vimrc"
|
The initialization of this option is done after reading the ".vimrc"
|
||||||
and the other initializations, so that when the 'shell' option is set
|
and the other initializations, so that when the 'shell' option is set
|
||||||
there, the 'shellpipe' option changes automatically, unless it was
|
there, the 'shellpipe' option changes automatically, unless it was
|
||||||
@@ -6648,9 +6650,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
security reasons.
|
security reasons.
|
||||||
|
|
||||||
*'shellquote'* *'shq'*
|
*'shellquote'* *'shq'*
|
||||||
'shellquote' 'shq' string (default: ""; Win32, when 'shell' does not
|
'shellquote' 'shq' string (default: "")
|
||||||
contain powershell but contains "sh"
|
|
||||||
somewhere: "\"")
|
|
||||||
global
|
global
|
||||||
Quoting character(s), put around the command passed to the shell, for
|
Quoting character(s), put around the command passed to the shell, for
|
||||||
the "!" and ":!" commands. The redirection is kept outside of the
|
the "!" and ":!" commands. The redirection is kept outside of the
|
||||||
@@ -6658,9 +6658,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
probably not useful to set both options.
|
probably not useful to set both options.
|
||||||
This is an empty string by default. Only known to be useful for
|
This is an empty string by default. Only known to be useful for
|
||||||
third-party shells on MS-Windows-like systems, such as the MKS Korn
|
third-party shells on MS-Windows-like systems, such as the MKS Korn
|
||||||
Shell or bash, where it should be "\"". The default is adjusted
|
Shell or bash, where it should be "\"". See |dos-shell|.
|
||||||
according the value of 'shell', to reduce the need to set this option
|
|
||||||
by the user. See |dos-shell|.
|
|
||||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||||
security reasons.
|
security reasons.
|
||||||
|
|
||||||
@@ -6677,12 +6675,12 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
The default is ">". For Unix, if the 'shell' option is "csh" or
|
The default is ">". For Unix, if the 'shell' option is "csh" or
|
||||||
"tcsh" during initializations, the default becomes ">&". If the
|
"tcsh" during initializations, the default becomes ">&". If the
|
||||||
'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta",
|
'shell' option is "sh", "ksh", "mksh", "pdksh", "zsh", "zsh-beta",
|
||||||
"bash" or "fish", the default becomes ">%s 2>&1". This means that
|
"bash", "fish", or "pwsh", the default becomes ">%s 2>&1". This means
|
||||||
stderr is also included. For Win32, the Unix checks are done and
|
that stderr is also included. For Win32, the Unix checks are done and
|
||||||
additionally "cmd" is checked for, which makes the default ">%s 2>&1",
|
additionally "cmd" is checked for, which makes the default ">%s 2>&1",
|
||||||
and "powershell" is checked for which makes the default
|
and "powershell" is checked for which makes the default
|
||||||
"2>&1 | Out-File -Encoding default". Also, the same names with ".exe"
|
"2>&1 | Out-File -Encoding default" (see |dos-powershell|). Also, the
|
||||||
appended are checked for.
|
same names with ".exe" appended are checked for.
|
||||||
The initialization of this option is done after reading the ".vimrc"
|
The initialization of this option is done after reading the ".vimrc"
|
||||||
and the other initializations, so that when the 'shell' option is set
|
and the other initializations, so that when the 'shell' option is set
|
||||||
there, the 'shellredir' option changes automatically unless it was
|
there, the 'shellredir' option changes automatically unless it was
|
||||||
@@ -6697,7 +6695,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
global
|
global
|
||||||
{only for MS-Windows}
|
{only for MS-Windows}
|
||||||
When set, a forward slash is used when expanding file names. This is
|
When set, a forward slash is used when expanding file names. This is
|
||||||
useful when a Unix-like shell is used instead of cmd.exe or
|
useful when a Unix-like shell is used instead of cmd.exe, pwsh.exe, or
|
||||||
powershell.exe. Backward slashes can still be typed, but they are
|
powershell.exe. Backward slashes can still be typed, but they are
|
||||||
changed to forward slashes by Vim.
|
changed to forward slashes by Vim.
|
||||||
Note that setting or resetting this option has no effect for some
|
Note that setting or resetting this option has no effect for some
|
||||||
@@ -6767,10 +6765,10 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
then ')"' is appended.
|
then ')"' is appended.
|
||||||
When the value is '(' then also see 'shellxescape'.
|
When the value is '(' then also see 'shellxescape'.
|
||||||
This is an empty string by default on most systems, but is known to be
|
This is an empty string by default on most systems, but is known to be
|
||||||
useful for on Win32 version, either for cmd.exe and powershell.exe
|
useful for on Win32 version, either for cmd.exe, powershell.exe, or
|
||||||
which automatically strips off the first and last quote on a command,
|
pwsh.exe which automatically strips off the first and last quote on a
|
||||||
or 3rd-party shells such as the MKS Korn Shell or bash, where it
|
command, or 3rd-party shells such as the MKS Korn Shell or bash, where
|
||||||
should be "\"". The default is adjusted according the value of
|
it should be "\"". The default is adjusted according the value of
|
||||||
'shell', to reduce the need to set this option by the user. See
|
'shell', to reduce the need to set this option by the user. See
|
||||||
|dos-shell|.
|
|dos-shell|.
|
||||||
This option cannot be set from a |modeline| or in the |sandbox|, for
|
This option cannot be set from a |modeline| or in the |sandbox|, for
|
||||||
|
@@ -304,40 +304,80 @@ Vim sets the 'shellcmdflag' and 'shellquote' or 'shellxquote' options will be
|
|||||||
set as described above.
|
set as described above.
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
10. PowerShell *dos-powershell*
|
10. PowerShell *dos-powershell* *dos-pwsh*
|
||||||
|
|
||||||
Vim also supports Windows PowerShell. If 'shell' has been set to
|
Vim supports PowerShell Desktop and PowerShell Core. PowerShell Desktop is
|
||||||
"powershell.exe" at startup then VIM sets 'shellcmdflag', 'shellxquote',
|
the version of PowerShell that is installed with Windows, while PowerShell
|
||||||
'shellpipe', and 'shellredir' options to the following values:
|
Core is a separate downloadable version that works cross-platform. To see
|
||||||
|
which version you are using then enter the following in a PowerShell prompt -
|
||||||
|
$PSVersionTable.PSEdition
|
||||||
|
|
||||||
|
If 'shell' includes "powershell" in the filename at startup then VIM sets
|
||||||
|
'shellcmdflag', 'shellxquote', 'shellpipe', and 'shellredir' options to the
|
||||||
|
following values:
|
||||||
|
|
||||||
'shellcmdflag' -Command
|
'shellcmdflag' -Command
|
||||||
'shellxquote' "
|
'shellxquote' "
|
||||||
'shellpipe' 2>&1 | Out-File -Encoding default
|
'shellpipe' 2>&1 | Out-File -Encoding default
|
||||||
'shellredir' 2>&1 | Out-File -Encoding default
|
'shellredir' 2>&1 | Out-File -Encoding default
|
||||||
|
|
||||||
|
If 'shell' includes "pwsh" in the filename at startup then VIM sets
|
||||||
|
'shellcmdflag', 'shellxquote', 'shellpipe', and 'shellredir' options to the
|
||||||
|
following values:
|
||||||
|
|
||||||
|
'shellcmdflag' -c
|
||||||
|
'shellxquote' "
|
||||||
|
'shellpipe' >%s 2>&1
|
||||||
|
'shellredir' >%s 2>&1
|
||||||
|
|
||||||
If you find that PowerShell commands are taking a long time to run then try
|
If you find that PowerShell commands are taking a long time to run then try
|
||||||
setting 'shellcmdflag' to "-NoProfile -Command". Note this will prevent any
|
with "-NoProfile" at the beginning of the 'shellcmdflag'. Note this will
|
||||||
PowerShell environment setup by the profile from taking place.
|
prevent any PowerShell environment setup by the profile from taking place.
|
||||||
|
|
||||||
If you have problems running PowerShell scripts through the 'shell' then try
|
If you have problems running PowerShell scripts through the 'shell' then try
|
||||||
setting 'shellcmdflag' to "-ExecutionPolicy RemoteSigned -Command". See
|
with "-ExecutionPolicy RemoteSigned -Command" at the beginning of
|
||||||
online Windows documentation for more information on PowerShell Execution
|
'shellcmdflag'. See online Windows documentation for more information on
|
||||||
Policy settings.
|
PowerShell Execution Policy settings.
|
||||||
|
|
||||||
|
See |option-backslash| about including spaces in 'shellcmdflag' when using
|
||||||
|
multiple flags.
|
||||||
|
|
||||||
The 'shellpipe' and 'shellredir' option values re-encode the UTF-16le output
|
The 'shellpipe' and 'shellredir' option values re-encode the UTF-16le output
|
||||||
from Windows PowerShell to your currently configured console codepage. The
|
from PowerShell Desktop to your currently configured console codepage. The
|
||||||
output can be forced into a different encoding by changing "default" to one of
|
output can be forced into a different encoding by changing "default" to one of
|
||||||
the following:
|
the following:
|
||||||
|
|
||||||
unicode - UTF-16le (default output from PowerShell 5.1)
|
unicode - UTF-16le (default output from PowerShell 5.1)
|
||||||
bigendianunicode - UTF-16
|
bigendianunicode - UTF-16
|
||||||
utf8 - UTF-8
|
utf8 - UTF-8
|
||||||
utf7 - UTF-7 (no-BOM)
|
utf7 - UTF-7 (no BOM)
|
||||||
utf32 - UTF-32
|
utf32 - UTF-32
|
||||||
ascii - 7-bit ASCII character set
|
ascii - 7-bit ASCII character set
|
||||||
default - System's active code page (typically ANSI)
|
default - System's active code page (typically ANSI)
|
||||||
oem - System's current OEM code page
|
oem - System's current OEM code page
|
||||||
|
|
||||||
Note Multi-byte Unicode encodings include a leading BOM.
|
Note The abovce multi-byte Unicode encodings include a leading BOM unless
|
||||||
|
otherwise indicated.
|
||||||
|
|
||||||
|
By default PowerShell Core's output is UTF-8 encoded without a BOM. If you
|
||||||
|
want to force the output of PowerShell Core into a different encoding then set
|
||||||
|
'shellredir' and 'shellpipe' to "2>&1 | Out-File -Encoding encoding" where
|
||||||
|
encoding is one of the following:
|
||||||
|
|
||||||
|
ascii - 7-bit ASCII character set
|
||||||
|
bigendianunicode - UTF-16be
|
||||||
|
bigendianutf32 - UTF-32be
|
||||||
|
oem - System's current OEM code page
|
||||||
|
unicode - UTF-16le
|
||||||
|
utf7 - UTF-7
|
||||||
|
utf8 - UTF-8
|
||||||
|
utf8BOM - UTF-8, with BOM
|
||||||
|
utf8NoBOM - UTF-8, no BOM (default output from PowerShell Core)
|
||||||
|
utf32 - UTF-32
|
||||||
|
|
||||||
|
Since PowerShell Core 6.2, the Encoding parameter also supports specifying a
|
||||||
|
numeric ID of a registered code page (-Encoding 1251) or string names of
|
||||||
|
registered code pages (-Encoding "windows-1251"). The .NET documentation for
|
||||||
|
Encoding.CodePage has more information
|
||||||
|
|
||||||
vim:tw=78:ts=8:noet:ft=help:norl:
|
vim:tw=78:ts=8:noet:ft=help:norl:
|
||||||
|
@@ -30,6 +30,7 @@ File formats |dos-file-formats|
|
|||||||
Interrupting |dos-CTRL-Break|
|
Interrupting |dos-CTRL-Break|
|
||||||
Temp files |dos-temp-files|
|
Temp files |dos-temp-files|
|
||||||
Shell option default |dos-shell|
|
Shell option default |dos-shell|
|
||||||
|
PowerShell defaults |dos-powershell|
|
||||||
|
|
||||||
Win32 GUI |gui-w32|
|
Win32 GUI |gui-w32|
|
||||||
|
|
||||||
|
@@ -5222,6 +5222,7 @@ vim_tempname(
|
|||||||
WCHAR *chartab = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
WCHAR *chartab = L"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
char_u *retval;
|
char_u *retval;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
char_u *shname;
|
||||||
long i;
|
long i;
|
||||||
|
|
||||||
wcscpy(itmp, L"");
|
wcscpy(itmp, L"");
|
||||||
@@ -5247,8 +5248,10 @@ vim_tempname(
|
|||||||
// "sh". NOTE: This also checks 'shellcmdflag' to help those people who
|
// "sh". NOTE: This also checks 'shellcmdflag' to help those people who
|
||||||
// didn't set 'shellslash' but only if not using PowerShell.
|
// didn't set 'shellslash' but only if not using PowerShell.
|
||||||
retval = utf16_to_enc(itmp, NULL);
|
retval = utf16_to_enc(itmp, NULL);
|
||||||
if ((strstr((char *)gettail(p_sh), "powershell") == NULL
|
shname = gettail(p_sh);
|
||||||
&& *p_shcf == '-') || p_ssl)
|
if ((*p_shcf == '-' && !(strstr((char *)shname, "powershell") != NULL
|
||||||
|
|| strstr((char *)shname, "pwsh") != NULL ))
|
||||||
|
|| p_ssl)
|
||||||
for (p = retval; *p; ++p)
|
for (p = retval; *p; ++p)
|
||||||
if (*p == '\\')
|
if (*p == '\\')
|
||||||
*p = '/';
|
*p = '/';
|
||||||
|
14
src/misc2.c
14
src/misc2.c
@@ -1414,8 +1414,9 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline)
|
|||||||
char_u *escaped_string;
|
char_u *escaped_string;
|
||||||
int l;
|
int l;
|
||||||
int csh_like;
|
int csh_like;
|
||||||
# ifdef MSWIN
|
char_u *shname;
|
||||||
int powershell;
|
int powershell;
|
||||||
|
# ifdef MSWIN
|
||||||
int double_quotes;
|
int double_quotes;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -1425,9 +1426,12 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline)
|
|||||||
// Csh also needs to have "\n" escaped twice when do_special is set.
|
// Csh also needs to have "\n" escaped twice when do_special is set.
|
||||||
csh_like = csh_like_shell();
|
csh_like = csh_like_shell();
|
||||||
|
|
||||||
|
// PowerShell uses it's own version for quoting single quotes
|
||||||
|
shname = gettail(p_sh);
|
||||||
|
powershell = strstr((char *)shname, "pwsh") != NULL;
|
||||||
# ifdef MSWIN
|
# ifdef MSWIN
|
||||||
// PowerShell only accepts single quotes so override p_ssl.
|
powershell = powershell || strstr((char *)shname, "powershell") != NULL;
|
||||||
powershell = strstr((char *)gettail(p_sh), "powershell") != NULL;
|
// PowerShell only accepts single quotes so override shellslash.
|
||||||
double_quotes = !powershell && !p_ssl;
|
double_quotes = !powershell && !p_ssl;
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@@ -1445,11 +1449,9 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline)
|
|||||||
# endif
|
# endif
|
||||||
if (*p == '\'')
|
if (*p == '\'')
|
||||||
{
|
{
|
||||||
# ifdef MSWIN
|
|
||||||
if (powershell)
|
if (powershell)
|
||||||
length +=2; // ' => ''
|
length +=2; // ' => ''
|
||||||
else
|
else
|
||||||
# endif
|
|
||||||
length += 3; // ' => '\''
|
length += 3; // ' => '\''
|
||||||
}
|
}
|
||||||
if ((*p == '\n' && (csh_like || do_newline))
|
if ((*p == '\n' && (csh_like || do_newline))
|
||||||
@@ -1497,14 +1499,12 @@ vim_strsave_shellescape(char_u *string, int do_special, int do_newline)
|
|||||||
# endif
|
# endif
|
||||||
if (*p == '\'')
|
if (*p == '\'')
|
||||||
{
|
{
|
||||||
# ifdef MSWIN
|
|
||||||
if (powershell)
|
if (powershell)
|
||||||
{
|
{
|
||||||
*d++ = '\'';
|
*d++ = '\'';
|
||||||
*d++ = '\'';
|
*d++ = '\'';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
# endif
|
|
||||||
{
|
{
|
||||||
*d++ = '\'';
|
*d++ = '\'';
|
||||||
*d++ = '\\';
|
*d++ = '\\';
|
||||||
|
12
src/option.c
12
src/option.c
@@ -933,8 +933,8 @@ set_init_3(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
# ifdef MSWIN
|
# ifdef MSWIN
|
||||||
// PowerShell 5.1/.NET outputs UTF-16 with BOM so re-encode to the
|
// Windows PowerShell output is UTF-16 with BOM so re-encode to the
|
||||||
// current codepage
|
// current codepage.
|
||||||
else if ( fnamecmp(p, "powershell") == 0
|
else if ( fnamecmp(p, "powershell") == 0
|
||||||
|| fnamecmp(p, "powershell.exe") == 0
|
|| fnamecmp(p, "powershell.exe") == 0
|
||||||
)
|
)
|
||||||
@@ -965,6 +965,7 @@ set_init_3(void)
|
|||||||
|| fnamecmp(p, "fish") == 0
|
|| fnamecmp(p, "fish") == 0
|
||||||
|| fnamecmp(p, "ash") == 0
|
|| fnamecmp(p, "ash") == 0
|
||||||
|| fnamecmp(p, "dash") == 0
|
|| fnamecmp(p, "dash") == 0
|
||||||
|
|| fnamecmp(p, "pwsh") == 0
|
||||||
# ifdef MSWIN
|
# ifdef MSWIN
|
||||||
|| fnamecmp(p, "cmd") == 0
|
|| fnamecmp(p, "cmd") == 0
|
||||||
|| fnamecmp(p, "sh.exe") == 0
|
|| fnamecmp(p, "sh.exe") == 0
|
||||||
@@ -976,6 +977,7 @@ set_init_3(void)
|
|||||||
|| fnamecmp(p, "bash.exe") == 0
|
|| fnamecmp(p, "bash.exe") == 0
|
||||||
|| fnamecmp(p, "cmd.exe") == 0
|
|| fnamecmp(p, "cmd.exe") == 0
|
||||||
|| fnamecmp(p, "dash.exe") == 0
|
|| fnamecmp(p, "dash.exe") == 0
|
||||||
|
|| fnamecmp(p, "pwsh.exe") == 0
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -985,7 +987,10 @@ set_init_3(void)
|
|||||||
# ifdef MSWIN
|
# ifdef MSWIN
|
||||||
p_sp = (char_u *)">%s 2>&1";
|
p_sp = (char_u *)">%s 2>&1";
|
||||||
# else
|
# else
|
||||||
p_sp = (char_u *)"2>&1| tee";
|
if (fnamecmp(p, "pwsh") == 0)
|
||||||
|
p_sp = (char_u *)">%s 2>&1";
|
||||||
|
else
|
||||||
|
p_sp = (char_u *)"2>&1| tee";
|
||||||
# endif
|
# endif
|
||||||
options[idx_sp].def_val[VI_DEFAULT] = p_sp;
|
options[idx_sp].def_val[VI_DEFAULT] = p_sp;
|
||||||
}
|
}
|
||||||
@@ -1011,6 +1016,7 @@ set_init_3(void)
|
|||||||
* p_shcf p_sxq
|
* p_shcf p_sxq
|
||||||
* cmd.exe - "/c" "("
|
* cmd.exe - "/c" "("
|
||||||
* powershell.exe - "-Command" "\""
|
* powershell.exe - "-Command" "\""
|
||||||
|
* pwsh.exe - "-c" "\""
|
||||||
* "sh" like shells - "-c" "\""
|
* "sh" like shells - "-c" "\""
|
||||||
*
|
*
|
||||||
* For Win32 p_sxq is set instead of p_shq to include shell redirection.
|
* For Win32 p_sxq is set instead of p_shq to include shell redirection.
|
||||||
|
@@ -2135,6 +2135,7 @@ executable_exists(char *name, char_u **path, int use_path, int use_pathext)
|
|||||||
char_u *pathbuf = NULL;
|
char_u *pathbuf = NULL;
|
||||||
char_u *pathext = NULL;
|
char_u *pathext = NULL;
|
||||||
char_u *pathextbuf = NULL;
|
char_u *pathextbuf = NULL;
|
||||||
|
char_u *shname = NULL;
|
||||||
int noext = FALSE;
|
int noext = FALSE;
|
||||||
int retval = FALSE;
|
int retval = FALSE;
|
||||||
|
|
||||||
@@ -2142,8 +2143,10 @@ executable_exists(char *name, char_u **path, int use_path, int use_pathext)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Using the name directly when a Unix-shell like 'shell'.
|
// Using the name directly when a Unix-shell like 'shell'.
|
||||||
if (strstr((char *)gettail(p_sh), "powershell") == NULL
|
shname = gettail(p_sh);
|
||||||
&& strstr((char *)gettail(p_sh), "sh") != NULL)
|
if (strstr((char *)shname, "sh") != NULL &&
|
||||||
|
!(strstr((char *)shname, "powershell") != NULL
|
||||||
|
|| strstr((char *)shname, "pwsh") != NULL))
|
||||||
noext = TRUE;
|
noext = TRUE;
|
||||||
|
|
||||||
if (use_pathext)
|
if (use_pathext)
|
||||||
|
@@ -19,7 +19,8 @@ func Test_shell_options()
|
|||||||
\ ['ash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
|
\ ['ash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
|
||||||
\ ['dash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
|
\ ['dash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''],
|
||||||
\ ['csh', '-c', '|& tee', '', '>&', '', ''],
|
\ ['csh', '-c', '|& tee', '', '>&', '', ''],
|
||||||
\ ['tcsh', '-c', '|& tee', '', '>&', '', '']]
|
\ ['tcsh', '-c', '|& tee', '', '>&', '', ''],
|
||||||
|
\ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '', '']]
|
||||||
endif
|
endif
|
||||||
if has('win32')
|
if has('win32')
|
||||||
let shells += [['cmd', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', ''],
|
let shells += [['cmd', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', ''],
|
||||||
@@ -28,6 +29,8 @@ func Test_shell_options()
|
|||||||
\ '', '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'],
|
\ '', '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'],
|
||||||
\ ['powershell', '-Command', '2>&1 | Out-File -Encoding default', '',
|
\ ['powershell', '-Command', '2>&1 | Out-File -Encoding default', '',
|
||||||
\ '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'],
|
\ '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'],
|
||||||
|
\ ['pwsh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
|
||||||
|
\ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
|
||||||
\ ['sh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
|
\ ['sh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
|
||||||
\ ['ksh.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', '"&|<>()@^', '"'],
|
\ ['mksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'],
|
||||||
@@ -61,6 +64,7 @@ func Test_shell_options()
|
|||||||
let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'"
|
let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'"
|
||||||
let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'"
|
let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'"
|
||||||
elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$'
|
elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$'
|
||||||
|
\ || e[0] =~# '.*pwsh$' || e[0] =~# '.*pwsh.exe$'
|
||||||
let str1 = "'cmd \"arg1\" ''arg2'' !%#'"
|
let str1 = "'cmd \"arg1\" ''arg2'' !%#'"
|
||||||
let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\#'"
|
let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\#'"
|
||||||
else
|
else
|
||||||
@@ -76,9 +80,14 @@ func Test_shell_options()
|
|||||||
let [&shellcmdflag, &shellpipe, &shellquote, &shellredir,
|
let [&shellcmdflag, &shellpipe, &shellquote, &shellredir,
|
||||||
\ &shellxescape, &shellxquote] = e[1:6]
|
\ &shellxescape, &shellxquote] = e[1:6]
|
||||||
new
|
new
|
||||||
r !echo hello
|
try
|
||||||
call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0])
|
r !echo hello
|
||||||
bwipe!
|
call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0])
|
||||||
|
catch
|
||||||
|
call assert_report('Failed to run shell command, shell: ' .. e[0])
|
||||||
|
finally
|
||||||
|
bwipe!
|
||||||
|
endtry
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
set shell& shellcmdflag& shellpipe& shellquote&
|
set shell& shellcmdflag& shellpipe& shellquote&
|
||||||
@@ -149,6 +158,8 @@ func Test_shellslash()
|
|||||||
" ".*\\\\[^\\\\]*$"
|
" ".*\\\\[^\\\\]*$"
|
||||||
let shells = [['cmd', '/c', '\\', '/'],
|
let shells = [['cmd', '/c', '\\', '/'],
|
||||||
\ ['powershell', '-Command', '\\', '/'],
|
\ ['powershell', '-Command', '\\', '/'],
|
||||||
|
\ ['pwsh', '-Command', '\\', '/'],
|
||||||
|
\ ['pwsh', '-c', '\\', '/'],
|
||||||
\ ['sh', '-c', '/', '/']]
|
\ ['sh', '-c', '/', '/']]
|
||||||
for e in shells
|
for e in shells
|
||||||
exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1]
|
exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1]
|
||||||
|
@@ -755,6 +755,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3079,
|
||||||
/**/
|
/**/
|
||||||
3078,
|
3078,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user