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: Greg Wooledge
Subject: Re: "here document" causing failures. Implementation is inconsistent and not documented.
Date: Tue, 10 Oct 2023 22:48:00 -0400

On Wed, Oct 11, 2023 at 11:56:42AM +1100, 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/
> 
> Trailing white space after the start of the here statement is ignored.

To be fair, whitespace *is* possible within the delimiting word, if
the word is quoted.

unicorn:~$ ebase -host localhost
unicorn:~$ cat <<'EOF  '
> EOF
> EOF  
EOF

In the example above, there are two spaces on the second line which
starts with '> EOF'.  The first line has no trailing whitespace, so
it doesn't match the delimiting word.  The second line has the two
trailing spaces, so it matches.

The shell is acting correctly here; if you feel the documentation could
be improved, that's fair.  But it seems fairly clear to me:

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



reply via email to

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