Zvi Har'El wrote:
> I think you should not escape any characters. You don't have to guess 
> which characters are special for the particular shell. Just give the 
> original name as you received it.
> 
> On 10/11/07 23:28, Bram Moolenaar wrote:
> 
>> Zvi Har'El wrote:
>>
>>   
>>> I feel vim has a bug in the case the name the file contain parentheses.
>>> The "%" string contains in this case  backslashes.  For example:
>>>
>>>
>>> $ls -l 'JVs America (article).html'
>>> -rw-r--r-- 1 rl gileadweb 31426 2007-11-10 19:16 JVs America (article).htm
>>>
>>>
>>>  $ vi +'!/bin/echo "%"' +x -e -s 'JVs America (article).html'
>>> JVs America \(article\).html
>>>
>>>
>>> $ vi +'!/bin/ls "%"' +x -e -s 'JVs America (article).html'
>>>
>>> /bin/ls: JVs America \(article\).html: No such file or directory
>>>     
>>
>> This is indeed inconsistent.  Vim should either escape the space as
>> well, so that you can leave out the quotes, or not escape special
>> characters, so that you can use quotes.  I'm not sure which one is the
>> best solution.

Currently, when doing file name completion in the shell, bash will add 
escaping backslashes and pass the whole name as one argv[] element. However,


        touch 'a (b) c'
        vim +'/bin/ls %' +x -e -s a<Tab>

which the shell completes to

        vim +'/bin/ls %' +x -e -s a\ \(b\)\ c

doesn't work:
/bin/ls: cannot access a: No such file or directory
/bin/ls: cannot access (b): No such file or directory
/bin/ls: cannot access c: No such file or directory

What does work is

        vim +'/bin/ls %' +x -e -s 'a\ (b)\ c'

which replies

a (b) c

This is paradoxical, since in interactive mode

        vim 'a\ (b)\ c'

displays the file name as

a\ (b)\ c

on the status line, then

        :!ls %

returns

a (b) c

which is apparently not the file being edited, while

        vim a\ \(b\)\ c

(or "vim a<Tab>" with bash completion) shows

a (b) c

but

        :!ls %

replies

ls: cannot access a: No such file or directory
ls: cannot access (b): No such file or directory
ls: cannot access c: No such file or directory

shell returned 2

press ENTER or type command to continue



IMHO, passing % to an external :! command ought to work, but is it feasible? 
Can Vim know which characters must be backslash-escaped in which shell? On my 
Linux system there are at least sh, ash, bash, csh, tcsh, ksh, zsh.


Best regards,
Tony.
-- 
Sure, Reagan has promised to take senility tests.  But what if he
forgets?

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui