Am 16.02.2012 22:05, schrieb Bram Moolenaar:
Andy Wokula wrote:
Am 16.02.2012 05:54, schrieb Bram Moolenaar:
Ben Fritz wrote:
I think we should do the auto-escaping, with shellxquote=(, and
additionally add a help note by :! and system() that "According to
the Microsoft documentation for cmd.exe, you either need to escape
(with a ^ character) any of these characters appearing literally in
your command, or surround them in quotes ("):> ( ) @ ^ |." Should
we mention that Vim will escape them again, and also escape "?
Yes, I think the user should escape& and | when they appear in a
command. I haven't verified, but I believe they are illegal in a file
name.
`|' is illegal in a file name, but `&' is not.
Weird.
Characters with special meaning [1]: "< > |& ( ) @ ^
Characters that can't be used in file names: "< > | * ?
Characters to be escaped [2] in a file name: Space& ( ) @ ^
[1] Vim should escape these with `^'
[2] prepend `^' or enclose file name in quotes
Please try the patch below. I currently do not have a Windows
machine to try this out.
Does the patch escape special characters? I can't see code for it.
Again, suggested settings are:
shellcmdflag: /c
shellxquote: (
escape special characters with `^'
I am against automatic escaping, because it makes it impossible to
have a& separate two commands. The user should do the escaping.
No, it's different between `('...`)':
An escaped `&' separates two commands, for example:
cmd /c (command1 ^& command2)
To get a literal `&', one has to write `^^^&':
cmd /c (notepad my^^^&file.txt)
(the file name is `my&file.txt')
Generally, Vim should do as little as possible. We currently don't do
any of this ^ escaping, I am very hesitant to start this now.
Ok, but the only thing that worries me at the moment is to get the right
set of special characters.
The user executes in Vim
:!notepad my^&file.txt & dir
Vim executes
cmd /c (notepad my^^^&file.txt ^& dir)
cmd.exe does the unescaping while parsing the argument, and finally executes
notepad my^&file.txt & dir
The same with quotes:
:!notepad "my&file.txt" & dir
-> cmd /c (notepad ^"my^&file.txt^" ^& dir)
-> notepad "my&file.txt" & dir
Also because it is unclear to me where the un-escaping is done. The
echo example is confusing.
cmd.exe unescapes text after `('.
IMHO shellxquote = '"(' should not be supported, it was an
intermediate solution with its own problems.
I thought the conclusion was this was the best solution overall.
What are the problems?
Above example (= mattn's original request) doesn't work:
:!notepad "my&file.txt"
-> cmd /s /c "(notepad "my&file.txt")"
Error: command "file.txt")"" not found
--
Andy
--
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