Suggestions to triple quoted strings proposal

Stepan Koltsov stepan.koltsov at gmail.com
Wed Dec 13 18:50:33 PST 2006


On 12/13/06, Bob Ippolito <bob at redivi.com> wrote:
> On 12/13/06, Stepan Koltsov <stepan.koltsov at gmail.com> wrote:
> > I've read proposal of triple quoted strings at
...
> > And I have two suggestions.
...
> Eh. String should just grow a method to do that. Literals are literals
> and should be treated as such.

We can call them "heredocs". It is term from bash man page.

I've found two operators: "<<" and "<<-" in bash man page. "<<"
ignores first newline. "<<-" also (surprise!) strips "all leading tab
characters from input lines and the line containing delimiter" (from
bash javadoc). From that man page:

===
This allows here-documents within shell scripts to be indented in a
natural fashion.
===

Wow! This is what I want for ES4.

Example of bash script:

===
#!/bin/bash -e

if true; then
    cat <<- FEOF
    line 1
    line 2
    FEOF
fi

cat << EOF
line 3
line 4
EOF
===

It prints:

===
line 1
line 2
line 3
line 4
===


I'm going to dig Python libraries to find the "most common use-case".

--
Stepan



More information about the Es4-discuss mailing list