bug-bash
[Top][All Lists]
Advanced

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

Re: "here document" causing failures. Implementation is inconsistent and


From: Chet Ramey
Subject: Re: "here document" causing failures. Implementation is inconsistent and not documented.
Date: Wed, 11 Oct 2023 09:19:14 -0400
User-agent: Mozilla Thunderbird

On 10/10/23 8:56 PM, Jim McD wrote:
Bug:
Trailing white space after the delimiting tag cause the here document to fail with an error like /./<script_name>: line <line_number>: warning: here-document at line <line_number> delimited by end-of-file (wanted `msg_end')Trailing white space/

This is not a bug.

Trailing white space after the start of the here statement is ignored.

That's how shell tokenization works; see below.

This doesn't appear to be documented anywhere. All the material I have seen on here documents I've seen so far never mention the requirement that the tag a the end must be free of any trailing white space.

If this text

"This  type  of  redirection  instructs the shell to read input from the
 current source until a line containing only delimiter (with no trailing
 blanks)  is  seen."

in the manual page doesn't convince you then maybe POSIX

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

will.

_Inconsistency _: If white space after the start of the here statement is permitted and ignored then it should be the same with a tag terminating the here statement.

Not at all. The delimiter (the word after the `<<' or `<<-') is a shell
word; words are delimited by metacharacters; white space is a
metacharacter. The white space is not part of the word.

The end of the here-document is likewise well-defined.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/




reply via email to

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