diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-09-28 15:51:37 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-09-28 15:51:37 +0200 |
commit | 1a613398068580ca1286ac2ed920f20c978aa662 (patch) | |
tree | 05b183b30f8ee99eea6288e9657f6213e7eacdb7 /src/ex_cmds.c | |
parent | 0f1c6708fdf17bb9c7305b8af5d12189956195b6 (diff) |
patch 8.1.2092: MS-Windows: redirect in system() does not workv8.1.2092
Problem: MS-Windows: redirect in system() does not work.
Solution: Handle 'shellxescape' and 'shellxquote' better. (Yasuhiro
Matsumoto, closes #2054)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r-- | src/ex_cmds.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c index 6ae5969a07..9d58ab41a5 100644 --- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -1762,12 +1762,21 @@ make_filter_cmd( STRCAT(buf, itmp); } #else - /* - * For shells that don't understand braces around commands, at least allow - * the use of commands in a pipe. - */ - STRCPY(buf, cmd); - if (itmp != NULL) + // For shells that don't understand braces around commands, at least allow + // the use of commands in a pipe. + if (*p_sxe != NUL && *p_sxq == '(') + { + if (itmp != NULL || otmp != NULL) + vim_snprintf((char *)buf, len, "(%s)", (char *)cmd); + else + STRCPY(buf, cmd); + if (itmp != NULL) + { + STRCAT(buf, " < "); + STRCAT(buf, itmp); + } + } + else { char_u *p; @@ -1819,18 +1828,20 @@ append_redir( char_u *end; end = buf + STRLEN(buf); - /* find "%s" */ + // find "%s" for (p = opt; (p = vim_strchr(p, '%')) != NULL; ++p) { - if (p[1] == 's') /* found %s */ + if (p[1] == 's') // found %s break; - if (p[1] == '%') /* skip %% */ + if (p[1] == '%') // skip %% ++p; } if (p != NULL) { - *end = ' '; /* not really needed? Not with sh, ksh or bash */ - vim_snprintf((char *)end + 1, (size_t)(buflen - (end + 1 - buf)), +#ifdef MSWIN + *end++ = ' '; // not really needed? Not with sh, ksh or bash +#endif + vim_snprintf((char *)end, (size_t)(buflen - (end - buf)), (char *)opt, (char *)fname); } else @@ -1838,7 +1849,7 @@ append_redir( #ifdef FEAT_QUICKFIX " %s %s", #else - " %s%s", /* " > %s" causes problems on Amiga */ + " %s%s", // " > %s" causes problems on Amiga #endif (char *)opt, (char *)fname); } |