Denys Vlasenko | 77b32cc | 2010-09-06 11:27:32 +0200 | [diff] [blame^] | 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 | 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 11 | -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 12 | c\ |
| 13 | EOF1 |
| 14 | echo |
| 15 | |
| 16 | echo Unquoted heredoc: |
| 17 | cat <<EOF2 |
| 18 | a\ |
| 19 | b |
| 20 | 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 21 | -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 22 | c\ |
| 23 | EOF2 |
| 24 | EOF2 |
| 25 | echo |
| 26 | |
| 27 | echo Quoted -heredoc: |
| 28 | cat <<-"EOF3" |
| 29 | a\ |
| 30 | b |
| 31 | 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 32 | -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 33 | c\ |
| 34 | EOF3 |
| 35 | # In -heredoc case the marker is detected even if it is indented. |
| 36 | echo |
| 37 | |
| 38 | echo Unquoted -heredoc: |
| 39 | cat <<-EOF4 |
| 40 | a\ |
| 41 | b |
| 42 | 123456 -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 43 | -$a-\t-\\-\"-\'-\`-\--\z-\*-\?- |
| 44 | c\ |
| 45 | EOF4 |
| 46 | EOF4 |
| 47 | # The marker is not detected if preceding line ends in backslash. |
| 48 | # TODO: marker should be detected even if it is split by line continuation: |
| 49 | # EOF\ |
| 50 | # 4 |
| 51 | # but currently hush doesn't do it. (Tab before "4" is not allowed, though.) |
| 52 | echo |
| 53 | |
| 54 | echo "Done: $?" |