1
0
forked from aniani/vim

patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a space

Problem:    MS-Windows: shell commands fail if &shell contains a space.
Solution:   Use quotes instead of escaping. (closes #4920)
This commit is contained in:
Bram Moolenaar
2019-10-05 12:09:32 +02:00
parent fd00c042af
commit 2efc44b3f0
6 changed files with 122 additions and 5 deletions

View File

@@ -4490,8 +4490,25 @@ mch_system_c(char *cmd, int options UNUSED)
{
int ret;
WCHAR *wcmd;
char_u *buf;
size_t len;
// If the command starts and ends with double quotes, enclose the command
// in parentheses.
len = STRLEN(cmd);
if (len >= 2 && cmd[0] == '"' && cmd[len - 1] == '"')
{
len += 3;
buf = alloc(len);
if (buf == NULL)
return -1;
vim_snprintf((char *)buf, len, "(%s)", cmd);
wcmd = enc_to_utf16(buf, NULL);
free(buf);
}
else
wcmd = enc_to_utf16((char_u *)cmd, NULL);
wcmd = enc_to_utf16((char_u *)cmd, NULL);
if (wcmd == NULL)
return -1;