On Sat, Mar 15, 2025, at 7:08 PM, MacBeth wrote: > On Sat, Mar 15, 2025 at 12:33 PM Greg Wooledge <g...@wooledge.org> wrote: >> On Sat, Mar 15, 2025 at 16:14:00 +0000, Nikola Novak via Bug reports for the >> GNU Bourne Again SHell wrote: >> > How do you end the heredoc with a multiline delimiter such as the >> > following: >> > >> > cat << "a >> > b" >> >> You don't. >> > > However you could fake it, by including backslashes in the delimiter, > which would allow literal newlines, but bash would ignore them as they > are escape sequences. So they wouldn't actually be a part of the > delimiter from bash's perspective, but merely visually and accepted > from the literal input. > > $ cat <<EOT\ > $ EOF > $ hello > $ goodbye > $ EOT\ > $ EOF > hello > goodbye > $
This doesn't work when quoting part of the delimiter -- a common thing to do. In this case, one has to use the "true" delimiter, which defeats the purpose. $ cat <<\EOT\ $$ EOF $$ hello $$ goodbye $$ EOT\ $$ EOF $$ \EOT\ $$ EOF $$ oh no $$ EOTEOF hello goodbye EOT\ EOF \EOT\ EOF oh no $ -- vq