Ben Fritz wrote:

> On Feb 19, 6:21 pm, mattn <[email protected]> wrote:
> > I got an error after applying this patch.
> >
> > :echo system("cat | grep foo", "foo")
> > grep: ): No such file or directory
> 
> Similar test, using Windows commands only:
> 
> :echo system('type mercurial.ini | findstr gvim')
> FINDSTR: cannot open )
> 
> However,
> :echo system('type mercurial.ini ^| findstr gvim')
> editor = gvim
> editor = gvim
> 
> As discussed in the thread responding to 7.3.443, both surrounding the
> command in parentheses AND escaping the special characters are needed.
> 
> Otherwise, the shell invoking cmd.exe treats something like type file
> | findstr as two commands, whereas escaping the | with ^ allows it to
> invoke cmd.exe with the entire line as a command, which the invoked
> cmd.exe then parses as two commands.
> 
> Probably a new option is needed telling the shell what to escape, and
> maybe with what.

Unfortunately it's not that simple.  With 7.3.4xx this command worked:

        echo system('ls "a&b" | grep "a&b"')

After patch 7.3.445 we get the error for the trailing ).
With escaping all special characters, which can currently be simulated
with:

        echo system('ls "a^&b" ^| grep "a^&b"')

Doesn't work, the ^& is not un-escaped.  This works:

        echo system('ls "a&b" ^| grep "a&b"')

So, what are the rules for escaping?  Do we need to detect
inside/outside double quotes?  Nope, this doesn't work:

        echo system('ls a^&b ^| grep a^&b')

And this doesn't work either:

        echo system('ls a&b ^| grep a&b')

Ah, Ben's suggestion to also escape the double quotes works:

        echo system('ls ^"a^&b^" ^| grep ^"a^&b^"')

Well, if we tell users that special characters in arguments, such as &
and | are to be enclosed in double quotes, then it does work escape all
the special characters.


-- 
If your nose runs, and your feet smell, you might be upside down.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui