diff options
-rw-r--r-- | src/ex_cmds.c | 24 | ||||
-rw-r--r-- | src/testdir/test_filter_cmd.vim | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 37 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 */ diff --git a/src/testdir/test_filter_cmd.vim b/src/testdir/test_filter_cmd.vim index 5aa5fa64df..86347ab77f 100644 --- a/src/testdir/test_filter_cmd.vim +++ b/src/testdir/test_filter_cmd.vim @@ -74,3 +74,16 @@ func Test_filter_cmd_completion() call assert_equal('filter /pat/ print', s:complete_filter_cmd('filter /pat/ pri')) call assert_equal('filter #pat# print', s:complete_filter_cmd('filter #pat# pri')) endfunc + +func Test_filter_cmd_with_filter() + new + set shelltemp + %!echo "a|b" + let out = getline(1) + bw! + if has('win32') + let out = trim(out, '" ') + endif + call assert_equal('a|b', out) + set shelltemp& +endfunction diff --git a/src/version.c b/src/version.c index def449a576..d4cccb941a 100644 --- a/src/version.c +++ b/src/version.c @@ -793,6 +793,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 468, +/**/ 467, /**/ 466, |