Author: Stan Eisenstat
Subject: Re: [Cs323] << failing question
Date: Thursday, 01 Oct 2020, 12:14:12
> Message Posted By: Unknown
>
> Can we fail right away if a line with << is syntactically incorrect? For
> example, say if the parenthesis is not balanced.
> i.e.
> (<< HERE file
>
> Do we have to get the here input or can we just fail?
As I posted earlier in reference to "<<a <<b":
Date: 27 Sep 2020 19:30:59 -0400 (Sun)
Subject: Re: [Cs323] here doc
...
Here are two ways to handle HERE documents:
1. Read the lines when the <<HERE is encountered, in
which case the first document will be read before the
second <<HERE is encountered and the error is detected.
2. Read the lines when the CMD struct containing the
HERE document is added to the CMD tree, in which case
the error is detected before the first document is
read.
Hwk2/parsley does the first, but the second is just as
reasonable. Thus the correct behavior (in terms of
whether the document is or is not read) is unspecified
and will not be tested.
Thus the behavior for "(<< HERE file" is unspecified.
Aside: bash avoids this problem by prompting for extra
lines until the parentheses balance.
--Stan-
PREV
INDEX
NEXT