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: Přemysl Šťastný
Subject: Re: Squiggly heredoc - new feature request
Date: Mon, 30 Aug 2021 23:22:47 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

Hi.

Thank for your answer.

Will ksh93 version ever get to upstream? This ugly 'bug' is here for decades and really irritates me and many people, who ever used shell for larger scripting and don't like to use tabs.

Best regards
P.

On 8/30/21 11:14 PM, Lawrence Velázquez wrote:
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


Attachment: OpenPGP_0x2FD4F23C65C1A5F0_and_old_rev.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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