blob: 501af54903c828b722cec4ddfd8e80ebebeb26b1
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 | 123456 `echo v'-$a-\t-\\-\"-\'-\`-\--\z-\*-\?-'` |
15 | 123456 $(echo v'-$a-\t-\\-\"-\'-\`-\--\z-\*-\?-') |
16 | c\ |
17 | EOF1 |
18 | echo |
19 | |
20 | echo Unquoted heredoc: |
21 | cat <<EOF2 |
22 | a\ |
23 | b |
24 | a\\ |
25 | b |
26 | 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
27 | -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
28 | 123456 `echo v'-$a-\t-\\-\"-\x-\`-\--\z-\*-\?-'` |
29 | 123456 $(echo v'-$a-\t-\\-\"-\x-\`-\--\z-\*-\?-') |
30 | c\ |
31 | EOF2 |
32 | EOF2 |
33 | echo |
34 | |
35 | echo Quoted -heredoc: |
36 | cat <<-"EOF3" |
37 | a\ |
38 | b |
39 | a\\ |
40 | b |
41 | 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
42 | -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
43 | 123456 `echo v'-$a-\t-\\-\"-\'-\`-\--\z-\*-\?-'` |
44 | 123456 $(echo v'-$a-\t-\\-\"-\'-\`-\--\z-\*-\?-') |
45 | c\ |
46 | EOF3 |
47 | # In -heredoc case the marker is detected even if it is indented. |
48 | echo |
49 | |
50 | echo Unquoted -heredoc: |
51 | cat <<-EOF4 |
52 | a\ |
53 | b |
54 | a\\ |
55 | b |
56 | 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
57 | -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
58 | 123456 `echo v'-$a-\t-\\-\"-\x-\`-\--\z-\*-\?-'` |
59 | 123456 $(echo v'-$a-\t-\\-\"-\x-\`-\--\z-\*-\?-') |
60 | c\ |
61 | EOF4 |
62 | EOF4 |
63 | # The marker is not detected if preceding line ends in backslash. |
64 | # TODO: marker should be detected even if it is split by line continuation: |
65 | # EOF\ |
66 | # 4 |
67 | # but currently hush doesn't do it. (Tab before "4" is not allowed, though.) |
68 | echo |
69 | |
70 | echo "Done: $?" |
71 |