Subject: bug#52496: syntax highlighting problem on emacs shell-script mode

From: Kévin Le Gouguec <[email-masked]>
Date: Sun, 19 Dec 2021 16:46:56 +0100

Andreas Schwab <[email-masked]> writes:

> On Dez 19 2021, Lars Ingebrigtsen wrote:
>
>> Andreas Schwab <[email-masked]> writes:
>>
>>> On Dez 19 2021, Lars Ingebrigtsen wrote:
>>>
>>>> Right.  I haven't real the shell documentation -- is "@" a valid heredoc
>>>> ... separator?
>>>
>>> Any word is.
>>
>> But is @ word constituent?
>
> A shell word can be almost anything.

Relevant part of (bash) Redirections:

>    The format of here-documents is:
>      [N]<<[-]WORD
>              HERE-DOCUMENT
>      DELIMITER
> 
>    No parameter and variable expansion, command substitution, arithmetic
> expansion, or filename expansion is performed on WORD.  If any part of
> WORD is quoted, the DELIMITER is the result of quote removal on WORD,

And (bash) Definitions:

> 'word'
>      A sequence of characters treated as a unit by the shell.  Words may
>      not include unquoted 'metacharacters'.

Preceded by:

> 'metacharacter'
>      A character that, when unquoted, separates words.  A metacharacter
>      is a 'space', 'tab', 'newline', or one of the following characters:
>      '|', '&', ';', '(', ')', '<', or '>'.

(AFAICT the same goes for POSIX sh[1])

So IIUC for here-documents anything is fair game except (1)
{single,double,back} quotes (2) metacharacters (3) backslashes and
comment openers (#); all of which can still be used if quoted or escaped
*on the opening line only*.

[1] https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04