On 2009-10-15, Christian Brabandt wrote:
> Hi,
>
> I have been playing with shellescape() lately and I think I have found
> at least one bug with how shellescape() works and have one suggestion
> for :h shellescape() to make thinks clear.
>
> Basically I wanted to execute printf "10,02d\n". So here is the script:
>
> let a='printf "10,%02d\n" 1'
> :exe '$r!'.shellescape(a,1)
>
> I expected it to return 10,01. But it didn't. It returned this error:
> bash: printf "10,%02d\n" 1: command not found
>
> I believe it does this, because bash is trying to execute the command
> 'printf "10,%02d\n"', which obviously does not exist. So apparently you
> have to shellescape each argument to the command separately, before
> executing the whole command, right?
Right.
> If this is true, I think the documentation :h shellescape() should be
> updated, like this, to make that clear:
>
> --- /home/chrisbra/local/share/vim/vim72/doc/eval.txt.old 2009-10-15
> 21:15:03.000000000 +0200
> +++ /home/chrisbra/local/share/vim/vim72/doc/eval.txt 2009-10-15
> 22:19:45.000000000 +0200
> @@ -5003,7 +5003,9 @@
> will enclose {string} in double quotes and double all double
> quotes within {string}.
> For other systems, it will enclose {string} in single quotes
> - and replace all "'" with "'\''".
> + and replace all "'" with "'\''". If you need to escape a
> + commandline consisting of several arguments, you have to
> + escape each argument separately.
> When the {special} argument is present and it's a non-zero
> Number or a non-empty String (|non-zero-arg|), then special
> items such as "!", "%", "#" and "<cword>" will be preceded by
The first line of ":help shellescape()" is:
Escape {string} for use as shell command argument.
That seems pretty clear to me.
Regards,
Gary
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---