summaryrefslogtreecommitdiffstats
path: root/src/ex_cmds.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-10-09 21:49:33 +0200
committerBram Moolenaar <Bram@vim.org>2018-10-09 21:49:33 +0200
commit0664089eccec1083dd04ef2255856fb34ce62f15 (patch)
tree3358c6be040a9af6dfa17849bec2ed8ee33617d8 /src/ex_cmds.c
parent1d3dbcf743be9c72a0df5fc0711553fce287d3f8 (diff)
patch 8.1.0468: MS-Windows: filter command with pipe character failsv8.1.0468
Problem: MS-Windows: Filter command with pipe character fails. (Johannes Riecken) Solution: Find the pipe character outside of quotes. (Yasuhiro Matsumoto, closes #1743, closes #3523)
Diffstat (limited to 'src/ex_cmds.c')
-rw-r--r--src/ex_cmds.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/ex_cmds.c b/src/ex_cmds.c
index 99c19f9136..0a5387c52b 100644
--- a/src/ex_cmds.c
+++ b/src/ex_cmds.c
@@ -1676,6 +1676,26 @@ do_shell(
apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf);
}
+#if !defined(UNIX)
+ static char_u *
+find_pipe(char_u *cmd)
+{
+ char_u *p;
+ int inquote = FALSE;
+
+ for (p = cmd; *p != NUL; ++p)
+ {
+ if (!inquote && *p == '|')
+ return p;
+ if (*p == '"')
+ inquote = !inquote;
+ else if (rem_backslash(p))
+ ++p;
+ }
+ return NULL;
+}
+#endif
+
/*
* Create a shell command from a command string, input redirection file and
* output redirection file.
@@ -1746,7 +1766,7 @@ make_filter_cmd(
*/
if (*p_shq == NUL)
{
- p = vim_strchr(buf, '|');
+ p = find_pipe(buf);
if (p != NULL)
*p = NUL;
}
@@ -1754,7 +1774,7 @@ make_filter_cmd(
STRCAT(buf, itmp);
if (*p_shq == NUL)
{
- p = vim_strchr(cmd, '|');
+ p = find_pipe(cmd);
if (p != NULL)
{
STRCAT(buf, " "); /* insert a space before the '|' for DOS */