Loading ...
Sorry, an error occurred while loading the content.
 

read a file in a variable

Expand Messages
  • Benoit Cerrina
    Hi, is there a way to read a file in a variable both on win32 and unix (on unix I d do let var=system( cat filename ) but I can t be sure that there is a cat
    Message 1 of 3 , Sep 30, 2001
      Hi,
      is there a way to read a file in a variable both on win32 and unix
      (on unix I'd do
      let var=system("cat filename")
      but I can't be sure that there is a cat on any win32 box and if I can
      I'd rather not require it.
      Benoit
    • Piet Delport
      ... Off the top of my head: if has( win32 ) || has( win95 ) || has( win16 ) || has( dos32 ) || has( dos16 ) let var=system( type foo ) else let var=system( cat
      Message 2 of 3 , Sep 30, 2001
        On Sun, 30 Sep 2001 at 18:13:04 +0200, Benoit Cerrina wrote:
        > Hi,
        > is there a way to read a file in a variable both on win32 and unix
        > (on unix I'd do
        > let var=system("cat filename")
        > but I can't be sure that there is a cat on any win32 box and if I can
        > I'd rather not require it.

        Off the top of my head:

        if has('win32') || has('win95') || has('win16') || has('dos32') || has('dos16')
        let var=system('type foo')
        else
        let var=system('cat foo')
        endif

        Untested, as usual. :-) And you can kill the has() tests for
        DOS/Windows variants you know you won't be supporting, of course.

        --
        Piet Delport <siberiyan@...>
        Today's subliminal thought is:
      • Benoit Cerrina
        Hi, I ve been thinking around the lines of if executable( cat ) let g:CatProg= cat else if executable( Type ) let g:CatProg= Type endif what do you think?
        Message 3 of 3 , Sep 30, 2001
          Hi,
          I've been thinking around the lines of
          if executable("cat")
          let g:CatProg="cat"
          else if executable("Type")
          let g:CatProg="Type"
          endif
          what do you think?
          Benoit
          ----- Original Message -----
          From: "Piet Delport" <siberiyan@...>
          To: "Benoit Cerrina" <b.cerrina@...>
          Cc: <vim@...>
          Sent: Sunday, September 30, 2001 8:15 PM
          Subject: Re: read a file in a variable
        Your message has been successfully submitted and would be delivered to recipients shortly.