Mercurial > vim
diff src/ex_cmds.c @ 14913:d4777be849d0 v8.1.0468
patch 8.1.0468: MS-Windows: filter command with pipe character fails
commit https://github.com/vim/vim/commit/0664089eccec1083dd04ef2255856fb34ce62f15
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Oct 9 21:49:33 2018 +0200
patch 8.1.0468: MS-Windows: filter command with pipe character fails
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 09 Oct 2018 22:00:07 +0200 |
parents | 27b9a84395b5 |
children | 6f2ce3b311de |
line wrap: on
line diff
--- 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 */