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

  • Thread starter Iñaki Baz Castillo
  • Start date
I

Iñaki Baz Castillo

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 <[email protected]>
 
S

Seebs

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
 
B

Bertram Scharpf

Hi,

Am Mittwoch, 30. Dez 2009, 10:10:05 +0900 schrieb Seebs:
=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>.
 
S

Seebs

Am Mittwoch, 30. Dez 2009, 10:10:05 +0900 schrieb Seebs:
`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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top