diff options
author | Bram Moolenaar <Bram@vim.org> | 2012-02-19 18:19:30 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2012-02-19 18:19:30 +0100 |
commit | 034b115568a1fc40b374b0b755d89f0a40f6d940 (patch) | |
tree | b2e6a8d5cd41cfe50311996e1fb8e6935981a5c8 /src/os_win32.c | |
parent | 5dc6252d331013e397a8d71e8f7ee9fd1cf514c1 (diff) | |
download | vim-034b115568a1fc40b374b0b755d89f0a40f6d940.zip |
updated for version 7.3.445
Problem: Can't properly escape commands for cmd.exe.
Solution: Default 'shellxquote' to '('. Append ')' to make '(command)'.
No need to use "/s" for 'shellcmdflag'.
Diffstat (limited to 'src/os_win32.c')
-rw-r--r-- | src/os_win32.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/os_win32.c b/src/os_win32.c index fbf077f6f..520a09544 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -3908,8 +3908,13 @@ mch_call_shell( newcmd = lalloc(cmdlen, TRUE); if (newcmd != NULL) { - char_u *cmdbase = (*cmd == '"' ? cmd + 1 : cmd); + char_u *cmdbase = cmd; + /* Skip a leading ", ( and "(. */ + if (*cmdbase == '"' ) + ++cmdbase; + if (*cmdbase == '(') + ++cmdbase; if ((STRNICMP(cmdbase, "start", 5) == 0) && vim_iswhite(cmdbase[5])) { STARTUPINFO si; @@ -3953,16 +3958,26 @@ mch_call_shell( * empty, keep the double quotes around the command. * Otherwise remove the double quotes, they aren't needed * here, because we don't use a shell to run the command. */ - if (*cmd == '"' && *p_sxq == NUL) + if (cmdbase > cmd) { - newcmd[0] = '"'; - STRCPY(newcmd + 1, cmdbase); - } - else - { - STRCPY(newcmd, cmdbase); - if (*cmd == '"' && *newcmd != NUL) - newcmd[STRLEN(newcmd) - 1] = NUL; + if (STRNCMP(cmd, p_sxq, cmd - cmdbase) != 0) + { + STRCPY(newcmd, cmd); + } + else + { + char_u *p; + + STRCPY(newcmd, cmdbase); + /* Remove a trailing ", ) and )" if they have a match + * at the start of the command. */ + p = newcmd + STRLEN(newcmd); + if (p > newcmd && p[-1] == '"' && *cmd == '"') + *--p = NUL; + if (p > newcmd && p[-1] == ')' + && (*cmd =='(' || cmd[1] == '(')) + *--p = NUL; + } } /* @@ -3970,7 +3985,7 @@ mch_call_shell( * inherit our handles which causes unpleasant dangling swap * files if we exit before the spawned process */ - if (CreateProcess (NULL, // Executable name + if (CreateProcess(NULL, // Executable name newcmd, // Command to execute NULL, // Process security attributes NULL, // Thread security attributes |