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:
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user