shell/ash.c+4 -3
| @@ -12735,21 +12735,22 @@ checkend: { |
| |
| if (striptabs) { |
| while (c == '\t') |
| - | c = pgetc(); |
| + | c = pgetc_eatbnl(); /* dash does pgetc() */ |
| + | /* (see heredoc_bkslash_newline3a.tests) */ |
| } |
| |
| markloc = out - (char *)stackblock(); |
| for (p = eofmark; STPUTC(c, out), *p; p++) { |
| if (c != *p) |
| goto more_heredoc; |
| - | /* FIXME: fails for backslash-newlined terminator: |
| + | /* dash still has this not fixed (as of 2025-08) |
| * cat <<EOF |
| * ... |
| * EO\ |
| * F |
| * (see heredoc_bkslash_newline2.tests) |
| */ |
| - | c = pgetc(); |
| + | c = pgetc_eatbnl(); /* dash does pgetc() */ |
| } |
| |
| if (c == '\n' || c == PEOF) { |
shell/ash_test/ash-heredoc/heredoc_bkslash_newline2a.right+1 -0
shell/ash_test/ash-heredoc/heredoc_bkslash_newline2a.tests+4 -0
| @@ -0,0 +1,4 @@ |
| + | cat <<-EOF |
| + | Ok1 |
| + | EO\ |
| + | F |
shell/ash_test/ash-heredoc/heredoc_bkslash_newline3.right+1 -0
shell/ash_test/ash-heredoc/heredoc_bkslash_newline3.tests+4 -0
| @@ -0,0 +1,4 @@ |
| + | cat <<EOF |
| + | Ok1 |
| + | \ |
| + | EOF |
shell/ash_test/ash-heredoc/heredoc_bkslash_newline3a.right+1 -0
shell/ash_test/ash-heredoc/heredoc_bkslash_newline3a.tests+4 -0
| @@ -0,0 +1,4 @@ |
| + | cat <<-EOF |
| + | Ok1 |
| + | \ |
| + | EOF |
shell/hush.c+10 -2
| @@ -4639,7 +4639,15 @@ static char *fetch_till_str(o_string *as_string, |
| past_EOL = heredoc.length; |
| /* Get 1st char of next line, possibly skipping leading tabs */ |
| do { |
| - | ch = i_getch(input); |
| + | if (heredoc_flags & HEREDOC_QUOTED) |
| + | ch = i_getch(input); |
| + | else { /* see heredoc_bkslash_newline3a.tests: |
| + | * cat <<-EOF |
| + | * <tab>\ |
| + | * <tab>EOF |
| + | */ |
| + | ch = i_getch_and_eat_bkslash_nl(input); |
| + | } |
| if (ch != EOF) |
| nommu_addchr(as_string, ch); |
| } while ((heredoc_flags & HEREDOC_SKIPTABS) && ch == '\t'); |
| @@ -4665,7 +4673,7 @@ static char *fetch_till_str(o_string *as_string, |
| prev = 0; /* not '\' */ |
| continue; |
| } |
| - | } |
| + | } /* if (\n or EOF) */ |
| if (ch == EOF) { |
| o_free(&heredoc); |
| return NULL; /* error */ |
shell/hush_test/hush-heredoc/heredoc_bkslash_newline2a.right+1 -0
shell/hush_test/hush-heredoc/heredoc_bkslash_newline2a.tests+4 -0
| @@ -0,0 +1,4 @@ |
| + | cat <<-EOF |
| + | Ok1 |
| + | EO\ |
| + | F |
shell/hush_test/hush-heredoc/heredoc_bkslash_newline3.right+1 -0
shell/hush_test/hush-heredoc/heredoc_bkslash_newline3.tests+4 -0
| @@ -0,0 +1,4 @@ |
| + | cat <<EOF |
| + | Ok1 |
| + | \ |
| + | EOF |
shell/hush_test/hush-heredoc/heredoc_bkslash_newline3a.right+1 -0
shell/hush_test/hush-heredoc/heredoc_bkslash_newline3a.tests+4 -0
| @@ -0,0 +1,4 @@ |
| + | cat <<-EOF |
| + | Ok1 |
| + | \ |
| + | EOF |