bug-bash
[Top][All Lists]
Advanced

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

Re: Squiggly heredoc - new feature request


From: Lawrence Velázquez
Subject: Re: Squiggly heredoc - new feature request
Date: Mon, 30 Aug 2021 17:14:32 -0400
User-agent: Cyrus-JMAP/3.5.0-alpha0-1125-g685cec594c-fm-20210825.001-g685cec59

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

-- 
vq



reply via email to

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