Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
On Thu, Mar 15, 2018 at 10:49:15PM +0100, Harald van Dijk wrote: > > It's perfectly consistent. It gets accepted at parse time, it only gets > rejected at expansion time. That's how dash generally behaves as well: > > $ dash -c 'echo ${x^}' > dash: 1: Bad substitution > $ dash -c ': || echo

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Harald van Dijk
On 15/03/2018 18:11, Herbert Xu wrote: On Thu, Mar 15, 2018 at 05:29:27PM +0100, Harald van Dijk wrote: That's because POSIX specifies that after ${, everything up to the matching }, not including nested strings, expansions, etc., is part of the word. No exception is made when it spans multiple

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
On Thu, Mar 15, 2018 at 05:29:27PM +0100, Harald van Dijk wrote: > > That's because POSIX specifies that after ${, everything up to the matching > }, not including nested strings, expansions, etc., is part of the word. No > exception is made when it spans multiple lines. > > Another instance of th

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Harald van Dijk
On 15/03/2018 15:52, Herbert Xu wrote: On Thu, Mar 15, 2018 at 12:41:10PM +0100, Harald van Dijk wrote: It is if you want to do it the way POSIX specifies. You're adding a special exception in the parser. I don't see how this approach can be extended to handle the other examples in my mail: I

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
On Thu, Mar 15, 2018 at 12:41:10PM +0100, Harald van Dijk wrote: > > It is if you want to do it the way POSIX specifies. You're adding a special > exception in the parser. I don't see how this approach can be extended to > handle the other examples in my mail: I don't think it's exactly clear what

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Harald van Dijk
On 15/03/2018 11:27, Herbert Xu wrote: Harald van Dijk wrote: Changing dash to support this would in my opinion be unreasonable, as it would require a total rewrite of the parser. I don't think it's that hard. It is if you want to do it the way POSIX specifies. You're adding a special exc

Re: Expansion-lookalikes in heredoc delimiters

2018-03-15 Thread Herbert Xu
Harald van Dijk wrote: > > Changing dash to support this would in my opinion be unreasonable, as it > would require a total rewrite of the parser. I don't think it's that hard. ---8<--- Subject: parser: Fix backquote support in here-document EOF mark Currently using backquotes in a here-docume

Re: Expansion-lookalikes in heredoc delimiters

2018-03-09 Thread Harald van Dijk
On 3/9/18 4:51 PM, Martijn Dekker wrote: Op 08-03-18 om 22:03 schreef Harald van Dijk: Consider this:   cat <<`bad`   `bad` As far as I can tell, this is technically valid, supposed to print nothing, and accepted in most other shells. [...] This is pretty clearly a case that no serious scr

Re: Expansion-lookalikes in heredoc delimiters

2018-03-09 Thread Martijn Dekker
Op 08-03-18 om 22:03 schreef Harald van Dijk: > Consider this: > >   cat <<`bad` >   `bad` > > As far as I can tell, this is technically valid, supposed to print > nothing, and accepted in most other shells. According to my tests, bash, ksh93, pdksh, mksh, zsh, and yash all accept it with no pro

Expansion-lookalikes in heredoc delimiters

2018-03-08 Thread Harald van Dijk
Consider this: cat <<`bad` `bad` As far as I can tell, this is technically valid, supposed to print nothing, and accepted in most other shells. POSIX Token Recognition says `bad` is to be recognised as a single token of type word, and any word can act as a heredoc delimiter. POSIX Here-