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.
*/
if (*p_shq == NUL)
{
- p = vim_strchr(buf, '|');
+ p = find_pipe(buf);
if (p != NULL)
*p = NUL;
}
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 */
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