bug-bash
[Top][All Lists]
Advanced

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

Re: Unclosed quotes on heredoc mode


From: Chet Ramey
Subject: Re: Unclosed quotes on heredoc mode
Date: Sat, 20 Nov 2021 15:19:33 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.2.1

On 11/20/21 12:35 PM, Robert Elz wrote:
     Date:        Sat, 20 Nov 2021 11:33:37 -0500
     From:        Chet Ramey <chet.ramey@case.edu>
     Message-ID:  <4addb789-50b6-12a5-7b8a-8a082abaa50d@case.edu>

   | I'm skeptical, but willing to be convinced. Bourne's shell allowed EOF to
   | terminate all sorts of things (quoted strings, command substitutions, here
   | documents) -- enough to make it purposeful.

More likely economical.   Making things fit in that sh was a real challenge.

Right. Purposeful.

That's a good starting point, provided you're willing to actually implement
that. That's what I'd like.

How about this. You show me examples where bash (devel bash) does what you
think is the wrong thing, and we agree it's a bug, I'll fix it.

 But for this you need to understand that
the shell has to parse and understand command substitutions, as they're read,
in order to correctly find the end,

The devel bash already does this. We've talked about it before. You need to
use bison, not byacc, and a new enough version of bison, but it works fine.

and a newline token in the middle of
a command substitution counts for a here doc operator that occurred before
it,

What does `counts' mean? You're not really reading the lines as shell
words, so a command substitution isn't really a command substitution while
you're reading the body of a here-document. You mean something like this?

cat << EOF
echo $(echo this EOF is
not the end of
the command substitution
EOF
but it is the end of the
here-document
)


and a here doc operator in a command substitution might not encounter
a newline until after the cmdsub text has ended - the next following newline
token provides there here doc text.

I can't imagine a useful example of this that isn't an error.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/



reply via email to

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