The shell script is erroring with
line 6: warning: here-document at line 2 delimited by end-of-file (wanted `_EOF_')
Here's the code:
#!/bin/bash
cat <<- _EOF_
test:
1. test
0. test test
_EOF_
But it is right.
#!/bin/bash
cat <<- _EOF_
test:
1. test
0. test test
_EOF_
From the Bash manual:
If the redirection operator is <<-, then all leading tab characters are stripped from input lines and the line containing delimiter. This allows here-documents within shell scripts to be indented in a natural fashion.
That is, it will fail if you have indented these lines with spaces, rather than tabs.
Another invisible problem is that the termination word must appear on the line, alone, with nothing around it. The only exception is leading tabs, if you use <<-
instead of <<
. So, a trailing space on the _EOF_
line would do this.
By the way, testing does show that Bash will tolerate a space between <<-
and the termination word, but it isn't shown as allowed in the Bash manual. This might be a portability problem.
The -
option to a here document <<-
suppresses leading tabs in the body of the document but not spaces.
So replace space with tabs then your warning messages will gone..
Example :
if true;
then
cat <<- _EOF_
test:
1. test
0. test test
_EOF_
fi
Reference Link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With