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.

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.

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

Test script
_______________________________________
#/usr/bin/bash
cat << msg_end

 Bash version
 $(bash --version)

msg_end
_______________________________________
> *# This fails*
*> cat -A test_here*
#/usr/bin/bash$
cat << msg_end       $
$
 Bash version$
 $(bash --version)$
  $
msg_end $
>
> *# This works*
*> cat -A test_here*
#/usr/bin/bash$
cat << msg_end       $
$
 Bash version$
 $(bash --version)$
  $
msg_end$
>
_____________________________________
Tested on these, all virtual machines excdept MSYS2 which runs alongside MS Win10. MS WSL2 is a virtual machine.
Output is from bash --version and uname -a commands.

Zorin Linux -
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Linux XXXX 5.15.0-78-generic #85~20.04.1-Ubuntu SMP Mon Jul 17 09:42:39 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

MS Windows WSL2 (Ubuntu)
GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
Linux XXXX 5.15.90.1-microsoft-standard-WSL2 #1 SMP Fri Jan 27 02:56:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

MS Windows MSYS2 (derived from Cygwin)
GNU bash, version 5.2.15(1)-release (x86_64-pc-msys)
MSYS_NT-10.0-19045 bob 3.4.6.x86_64 2023-02-15 18:03 UTC x86_64 Msys

Oracle on ARM
GNU bash, version 5.1.16(1)-release (aarch64-unknown-linux-gnu)
Linux ub01 5.15.0-1034-oracle #40-Ubuntu SMP Wed Apr 19 16:10:04 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux

Reply via email to