Wednesday, April 18, 2012

Re: echoing the contents of a registry to a /dev device

On 04/18/12 08:11, Chris Sutcliffe wrote:
> I'm trying to figure out a way to dump the contents of the '@@'
> registry (i.e. the registry populated by the yank command) to the
> /dev/clipboard device in Cygwin. Basically I'm trying:

You're awfully close, but I think you're reaching for the wrong
register. The

@"

register contains the most recent yank, not "@@". So you might try

> silent exe "!echo \"" .<somehow access @@> . "\"> /dev/clipboard"

silent exe "!echo \"".(@")."\"> /dev/clipboard"

Note that you still have command injection issues here, where, if
the contents of the register have shell metacharacters in it
(with double-quotes, dollar-signs can access variables, the "!"
can end up with shell expansion, and a literal
backslash-doublequote in your register will prematurely close the
string with odd results), or if you change to using
single-quotes, you mostly only have to concern yourself with
single-quotes in the register contents.

Alternatively, you might be able to do something like

call writefile([@"], '/dev/clipboard')

or

echo writefile([@"], '/dev/clipboard')?"Failed":"Succeeded"

which should write the contents with less opportunity for
escaping issues.

-tim

--
You received this message from the "vim_use" 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

No comments: