Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
14912:cf4333fc16bb | 14913:d4777be849d0 |
---|---|
1674 display_errors(); | 1674 display_errors(); |
1675 | 1675 |
1676 apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf); | 1676 apply_autocmds(EVENT_SHELLCMDPOST, NULL, NULL, FALSE, curbuf); |
1677 } | 1677 } |
1678 | 1678 |
1679 #if !defined(UNIX) | |
1680 static char_u * | |
1681 find_pipe(char_u *cmd) | |
1682 { | |
1683 char_u *p; | |
1684 int inquote = FALSE; | |
1685 | |
1686 for (p = cmd; *p != NUL; ++p) | |
1687 { | |
1688 if (!inquote && *p == '|') | |
1689 return p; | |
1690 if (*p == '"') | |
1691 inquote = !inquote; | |
1692 else if (rem_backslash(p)) | |
1693 ++p; | |
1694 } | |
1695 return NULL; | |
1696 } | |
1697 #endif | |
1698 | |
1679 /* | 1699 /* |
1680 * Create a shell command from a command string, input redirection file and | 1700 * Create a shell command from a command string, input redirection file and |
1681 * output redirection file. | 1701 * output redirection file. |
1682 * Returns an allocated string with the shell command, or NULL for failure. | 1702 * Returns an allocated string with the shell command, or NULL for failure. |
1683 */ | 1703 */ |
1744 * Don't do this when 'shellquote' is not empty, otherwise the | 1764 * Don't do this when 'shellquote' is not empty, otherwise the |
1745 * redirection would be inside the quotes. | 1765 * redirection would be inside the quotes. |
1746 */ | 1766 */ |
1747 if (*p_shq == NUL) | 1767 if (*p_shq == NUL) |
1748 { | 1768 { |
1749 p = vim_strchr(buf, '|'); | 1769 p = find_pipe(buf); |
1750 if (p != NULL) | 1770 if (p != NULL) |
1751 *p = NUL; | 1771 *p = NUL; |
1752 } | 1772 } |
1753 STRCAT(buf, " <"); /* " < " causes problems on Amiga */ | 1773 STRCAT(buf, " <"); /* " < " causes problems on Amiga */ |
1754 STRCAT(buf, itmp); | 1774 STRCAT(buf, itmp); |
1755 if (*p_shq == NUL) | 1775 if (*p_shq == NUL) |
1756 { | 1776 { |
1757 p = vim_strchr(cmd, '|'); | 1777 p = find_pipe(cmd); |
1758 if (p != NULL) | 1778 if (p != NULL) |
1759 { | 1779 { |
1760 STRCAT(buf, " "); /* insert a space before the '|' for DOS */ | 1780 STRCAT(buf, " "); /* insert a space before the '|' for DOS */ |
1761 STRCAT(buf, p); | 1781 STRCAT(buf, p); |
1762 } | 1782 } |