On Mon, Aug 30, 2021, at 4:06 PM, Přemysl Šťastný wrote:
I think, it would be nice, if you implemented Squiggly heredoc, which
solves this problem by ignoring both leading spaces and leading tabs. eg.
func()(
cat <<~ EOF
blabla
EOF
)
'<<~' is already syntactically valid.
bash-5.1$ cat <<~
heredoc> foo
heredoc> bar
heredoc> ~
foo
bar
bash-5.1$ cat <<~EOF
heredoc> foo
heredoc> bar
heredoc> ~EOF
foo
bar
bash-5.1$ echo abc >EOF; cat <<~ EOF
heredoc> foo
heredoc> bar
heredoc> ~
abc
ksh93s (I think) implemented a version of this behavior using '<<#'.
That's currently a syntax error in bash, unless interactive_comments
is disabled.
bash-5.1$ shopt -s interactive_comments
bash-5.1$ cat <<# EOF
bash: syntax error near unexpected token `newline'
bash-5.1$ shopt -u interactive_comments
bash-5.1$ echo abc >EOF; cat <<# EOF
heredoc> foo
heredoc> bar
heredoc> #
abc