Source-Changes archive

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

CVS commit: src/bin/sh



Module Name:    src
Committed By:   kre
Date:           Thu Sep  9 01:14:04 UTC 2021

Modified Files:
        src/bin/sh: parser.c

Log Message:
Fix a bug with here document processing reported on the austin group list
by oguzismailuysal%gmail.com@localhost (2021-09-08) (applies to all ash descendant
shells).

There were places in the parser where newline tokens were handled
without reading any pending here documents (leaving those until a
later newline token).

Eg: in
        : << do | for x in xxx
        do
        do echo $x
        done

The here doc text (<<do) should start immediately after the next newline
(which is after xxx).   But it wasn't happening until after the following
newline (after the line containing only "do").

Bizarrely, this
        : << do | for x in xxx
        do echo $x
        do
        done
"worked" because of that.

For other cases that also failed, see the hard_cases test case in
src/tests/bin/sh/t_here.sh   Note that there's nothing magic about
the particular end delimiter word chosen here, any will do, using
the ones selected for the tests (and shown here) simply makes it
all more mysterious!   The one here is the exact case reported.

Fix this by reading the here docs when processing newline tokens
when they are encountered in other than the "normal" way.   Whether
this catches every possibility is unknown currently - may never be
known for certain, but there are no more I can currently think of.

No pullups needed, this isn't a significant enough bug (ie: no one
actually writes code like this) to warrant that.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/bin/sh/parser.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.




Home | Main Index | Thread Index | Old Index