bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Heredoc with a multiline delimiter


From: Robert Elz
Subject: Re: Heredoc with a multiline delimiter
Date: Sun, 16 Mar 2025 08:18:12 +0700

    Date:        Sat, 15 Mar 2025 18:08:48 -0500
    From:        MacBeth <macbeth.112358@gmail.com>
    Message-ID:  
<CAGp4WjzSKg8G=nJRctwxeFXJ08ZrnGoGhGCKySL3ZMyiq1drJw@mail.gmail.com>


  | 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.

bash does, so does mksh, zsh, and bosh, most other shells don't.   Just
another annoying incompatibility.

(line joining using \ isn't technically an escape sequence, but that
detail is irrelevant here).

POSIX says:

        It is unspecified whether the line containing the trailing delimiter
        is itself subject to this line continuation.

which means that nothing is required to make that work.   Further, unless
bash documents it as working, it is free to change the way it works for
that at any time, so was anyone to take your advice and actually use that
method, then they'd be risking their code breaking in a subsequent release,
with perhaps no warning at all.

kre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]