diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-10-05 12:09:32 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-10-05 12:09:32 +0200 |
commit | 2efc44b3f0b6bd8307cb281af095e08e15ab1c24 (patch) | |
tree | 4245a8fef089e696e8eb6df87e02cafbc4d7806e /src/os_win32.c | |
parent | fd00c042afc40539447e798aadbd0a2219fdbdc1 (diff) | |
download | vim-git-2efc44b3f0b6bd8307cb281af095e08e15ab1c24.tar.gz |
patch 8.1.2115: MS-Windows: shell commands fail if &shell contains a spacev8.1.2115
Problem: MS-Windows: shell commands fail if &shell contains a space.
Solution: Use quotes instead of escaping. (closes #4920)
Diffstat (limited to 'src/os_win32.c')
-rw-r--r-- | src/os_win32.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/os_win32.c b/src/os_win32.c index 26005b24f..ce035570d 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -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; |