hush: fix handling of heredocs starting with empty lines

function                                             old     new   delta
parse_stream                                        2748    2759     +11

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-07-23 15:43:57 +02:00
parent ca2f831ead
commit d73cdbf84c
5 changed files with 20 additions and 0 deletions

View File

@ -0,0 +1,2 @@
Ok

View File

@ -0,0 +1,4 @@
cat <<EOF
Ok
EOF

View File

@ -4226,6 +4226,14 @@ static char *fetch_till_str(o_string *as_string,
int prev = 0; /* not \ */
int ch;
/* Starting with "" is necessary for this case:
* cat <<EOF
*
* xxx
* EOF
*/
heredoc.data = xzalloc(1); /* start as "", not as NULL */
goto jump_in;
while (1) {

View File

@ -0,0 +1,2 @@
Ok

View File

@ -0,0 +1,4 @@
cat <<EOF
Ok
EOF