Friday, April 1, 2011

Re: Problems using value returned by external command

On Apr 2, 4:52 am, Ben Schmidt <mail_ben_schm...@yahoo.com.au> wrote:
> On 2/04/11 12:57 PM, Spiros Bousbouras wrote:
>
>
>
> > The following on GNU/Linux with vim version 7.1
>
> > prompt>  cat myscript
> > #!/bin/sh
> > echo 1
>
> > prompt>  cat myscript.vim
> > function! Check()
> >      let l:r = system("./myscript")
> >      if l:r == "1"
> >          echo "Good"
> >      else
> >          echo "Length of l:r is" strlen(l:r)
> >          echoerr "l:r is" l:r
> >      endif
> > endfunction
>
> > I start a vim session and do
>
> > :source myscript.vim
> > :echo Check()
>
> > and get
>
> >      Length of l:r is 2
> >      Error detected while processing function Check:
> >      line    6:
> >      l:r is 1^@
> >      0
>
> > Replacing inside Check()
> >      if l:r == "1"
> > with
> >      if l:r == "1\000"
> > doesn't make any difference.
>
> Try
>
>        if l:r == "1\n"

Yes , that works , thank you.

> I think it's :echoerr that is not displaying the \n in the string
> correctly, but interpreting it as if it were \n in a buffer (which
> stands in place of \0). If you just used :echo you would see 1 followed
> by a blank line.

--
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: