hush: fix another corner case with backslashes in heredocs
[oweals/busybox.git] / shell / hush_test / hush-misc / heredoc_backslash1.tests
1 # Test for correct handling of backslashes.
2 # Note that some lines in each heredoc start with a tab.
3
4 a=qwerty
5
6 echo Quoted heredoc:
7 cat <<"EOF1"
8 a\
9         b
10 a\\
11         b
12  123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
13         -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
14 c\
15 EOF1
16 echo
17
18 echo Unquoted heredoc:
19 cat <<EOF2
20 a\
21         b
22 a\\
23         b
24  123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
25         -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
26 c\
27 EOF2
28 EOF2
29 echo
30
31 echo Quoted -heredoc:
32 cat <<-"EOF3"
33 a\
34         b
35 a\\
36         b
37  123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
38         -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
39 c\
40         EOF3
41 # In -heredoc case the marker is detected even if it is indented.
42 echo
43
44 echo Unquoted -heredoc:
45 cat <<-EOF4
46 a\
47         b
48 a\\
49         b
50  123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
51         -$a-\t-\\-\"-\'-\`-\--\z-\*-\?-
52 c\
53 EOF4
54         EOF4
55 # The marker is not detected if preceding line ends in backslash.
56 # TODO: marker should be detected even if it is split by line continuation:
57 # EOF\
58 # 4
59 # but currently hush doesn't do it. (Tab before "4" is not allowed, though.)
60 echo
61
62 echo "Done: $?"