How to avoid \ escaping when using "= <<-EOF" ?

Discussion in 'Ruby' started by Iñaki Baz Castillo, Dec 30, 2009.

  1. Hi, the following code

    =2D---------------------
    banner =3D <<-EOF
    /\/
    EOF
    puts banner
    =2D---------------------

    produces:

    =2D---------------------
    //
    =2D---------------------


    How could I avoid the "\" scaping so the text appears verbatim?
    Thanks a lot.

    =2D-=20
    I=C3=B1aki Baz Castillo <>
     
    Iñaki Baz Castillo, Dec 30, 2009
    #1
    1. Advertising

  2. Iñaki Baz Castillo

    Seebs Guest

    On 2009-12-30, Iñaki Baz Castillo <> wrote:
    > How could I avoid the "\" scaping so the text appears verbatim?
    > Thanks a lot.


    If any part of the listed modifier for the here document is quoted,
    the here document acts like single quotes:

    cat <<-'EOF'
    foo\bar$baz
    EOF
    =>
    foo\bar$baz

    (Note that the stripping of whitespace from the '-' still takes effect.)

    -s
    --
    Copyright 2009, all wrongs reversed. Peter Seebach /
    http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
     
    Seebs, Dec 30, 2009
    #2
    1. Advertising

  3. Hi,

    Am Mittwoch, 30. Dez 2009, 10:10:05 +0900 schrieb Seebs:
    > On 2009-12-30, I=F1aki Baz Castillo <> wrote:
    > > How could I avoid the "\" scaping so the text appears verbatim?
    > > Thanks a lot.

    >=20
    > If any part of the listed modifier for the here document is quoted,
    > the here document acts like single quotes:
    >=20
    > cat <<-'EOF'
    > foo\bar$baz
    > EOF
    > =3D>
    > foo\bar$baz


    `cat' is a shell command. I suppose you meant something like

    mystr =3D <<-'EOT'
    hello
    EOT

    > (Note that the stripping of whitespace from the '-' still takes effect.)


    The `-' just means that an indented "EOT" will close the here
    document; without it the "EOT" has to start in column 1. No
    whitespace will be stripped inside the string.

    Bertram


    --=20
    Bertram Scharpf
    Stuttgart, Deutschland/Germany
    *
    Discover String#notempty? at <http://raa.ruby-lang.org/project/step>.
     
    Bertram Scharpf, Dec 30, 2009
    #3
  4. Iñaki Baz Castillo

    Seebs Guest

    On 2009-12-30, Bertram Scharpf <> wrote:
    > Am Mittwoch, 30. Dez 2009, 10:10:05 +0900 schrieb Seebs:
    >> If any part of the listed modifier for the here document is quoted,
    >> the here document acts like single quotes:
    >>
    >> cat <<-'EOF'
    >> foo\bar$baz
    >> EOF
    >> =>
    >> foo\bar$baz


    > `cat' is a shell command. I suppose you meant something like


    .... Whoops. This is right next to comp.unix.shell in my reading list, and
    oddly, the feature appears to be nearly identical. Except for the
    different handling of -'MARKER'.

    -s
    --
    Copyright 2009, all wrongs reversed. Peter Seebach /
    http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
    http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
     
    Seebs, Dec 30, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexander Malkis
    Replies:
    8
    Views:
    532
    Alexander Malkis
    Apr 14, 2004
  2. Kobu
    Replies:
    10
    Views:
    640
    Keith Thompson
    Mar 4, 2005
  3. SpreadTooThin

    ifstream eof not reporting eof?

    SpreadTooThin, Jun 13, 2007, in forum: C++
    Replies:
    10
    Views:
    709
    James Kanze
    Jun 15, 2007
  4. drmario
    Replies:
    2
    Views:
    647
    Jerry Coffin
    Apr 7, 2008
  5. Jan Burse
    Replies:
    67
    Views:
    1,083
    Jan Burse
    Mar 14, 2012
Loading...

Share This Page