Rawest raw string literals

Jussi Piitulainen jussi.piitulainen at helsinki.fi
Fri Apr 21 08:23:59 EDT 2017


Tim Chase <python.list at tim.thechases.com> writes:

> On 2017-04-21 08:23, Jussi Piitulainen wrote:
>> Tim Chase writes:
>>> Bash:
>>>   cat <<EOT
>>>   "single and double" with \ and /
>>>   EOT
>>>
>>> PS: yes, bash's does interpolate strings, so you still need to do
>>> escaping within, but the arbitrary-user-specified-delimiter idea
>>> still holds.
>> 
>> If you put any quote characters in the initial EOT, it doesn't.
>> Quote removal on the EOT determines the actual EOT at the end.
>> 
>>   cat <<"EOT"
>>   Not expanding any $amount here
>>   EOT
>
> Huh, I just tested it and you're 100% right on that.  But I just
> re-read over that section of my `man bash` page and don't see anything
> that stands out as detailing this.  Is there something I missed in the
> docs?

It's in this snippet, yanked straight from the man page:

       The format of here-documents is:

              <<[-]word
                      here-document
              delimiter

       No  parameter expansion, command substitution, arithmetic expansion,
       or pathname expansion is performed on word.  If  any  characters  in
       word  are  quoted,  the  delimiter is the result of quote removal on
       word, and the lines in the here-document are not expanded.  If  word



More information about the Python-list mailing list