]>
Commit | Line | Data |
---|---|---|
8868edaf CR |
1 | # This program is free software: you can redistribute it and/or modify |
2 | # it under the terms of the GNU General Public License as published by | |
3 | # the Free Software Foundation, either version 3 of the License, or | |
4 | # (at your option) any later version. | |
5 | # | |
6 | # This program is distributed in the hope that it will be useful, | |
7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
9 | # GNU General Public License for more details. | |
10 | # | |
11 | # You should have received a copy of the GNU General Public License | |
12 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
13 | # | |
14 | # basics | |
15 | cat <<EOF | |
16 | a | |
17 | b | |
18 | c | |
19 | EOF | |
20 | read x <<EOF | |
21 | a | |
22 | b | |
23 | c | |
24 | EOF | |
25 | echo "$x" | |
26 | read x y <<\EOF | |
27 | $PS4 | |
28 | EOF | |
29 | echo "$x" | |
30 | ||
31 | # empty here-documents | |
32 | read x <<EOF | |
33 | EOF | |
34 | echo "$x" | |
35 | read x <<\EOF | |
36 | EOF | |
37 | echo "$x" | |
38 | read x <<EOF | |
39 | $empty | |
40 | EOF | |
41 | echo "$x" | |
ccc6cda3 | 42 | |
8868edaf | 43 | # check order and content of multiple here docs |
ccc6cda3 JA |
44 | cat << EOF1 << EOF2 |
45 | hi | |
46 | EOF1 | |
47 | there | |
48 | EOF2 | |
49 | ||
d166f048 JA |
50 | while read line1; do |
51 | read line2 <&3 | |
52 | echo $line1 - $line2 | |
53 | done <<EOF1 3<<EOF2 | |
54 | one | |
55 | two | |
56 | three | |
57 | EOF1 | |
58 | alpha | |
59 | beta | |
60 | gamma | |
61 | EOF2 | |
62 | ||
63 | ||
ccc6cda3 JA |
64 | # check quoted here-doc is protected |
65 | ||
66 | a=foo | |
67 | cat << 'EOF' | |
68 | hi\ | |
69 | there$a | |
70 | stuff | |
71 | EOF | |
72 | ||
73 | # check that quoted here-documents don't have \newline processing done | |
74 | ||
75 | cat << 'EOF' | |
76 | hi\ | |
77 | there | |
78 | EO\ | |
79 | F | |
80 | EOF | |
81 | true | |
82 | ||
83 | # check that \newline is removed at start of here-doc | |
84 | cat << EO\ | |
85 | F | |
86 | hi | |
87 | EOF | |
88 | ||
89 | # check that \newline removal works for here-doc delimiter | |
90 | cat << EOF | |
91 | hi | |
92 | EO\ | |
93 | F | |
94 | ||
d166f048 JA |
95 | # check operation of tab removal in here documents |
96 | cat <<- EOF | |
97 | tab 1 | |
98 | tab 2 | |
99 | tab 3 | |
100 | EOF | |
101 | ||
102 | # check appending of text to file from here document | |
d233b485 CR |
103 | rm -f ${TMPDIR}/bash-zzz |
104 | cat > ${TMPDIR}/bash-zzz << EOF | |
d166f048 JA |
105 | abc |
106 | EOF | |
d233b485 | 107 | cat >> ${TMPDIR}/bash-zzz << EOF |
d166f048 JA |
108 | def ghi |
109 | jkl mno | |
110 | EOF | |
d233b485 CR |
111 | cat ${TMPDIR}/bash-zzz |
112 | rm -f ${TMPDIR}/bash-zzz | |
d166f048 JA |
113 | |
114 | # make sure command printing puts the here-document as the last redirection | |
115 | # on the line, and the function export code preserves syntactic correctness | |
116 | fff() | |
117 | { | |
d233b485 | 118 | ed ${TMPDIR}/foo <<ENDOFINPUT >/dev/null |
d166f048 JA |
119 | /^name/d |
120 | w | |
121 | q | |
122 | ENDOFINPUT | |
123 | aa=1 | |
124 | } | |
125 | ||
126 | type fff | |
127 | export -f fff | |
128 | ${THIS_SH} -c 'type fff' | |
129 | ||
17345e5a JA |
130 | ${THIS_SH} ./heredoc1.sub |
131 | ||
ac50fbac CR |
132 | # test heredocs in command substitutions |
133 | ${THIS_SH} ./heredoc2.sub | |
ac50fbac | 134 | ${THIS_SH} ./heredoc3.sub |
d233b485 | 135 | ${THIS_SH} ./heredoc4.sub |
ac50fbac | 136 | |
8868edaf CR |
137 | # heredoc tests that use different size documents to test pipe implementation |
138 | ${THIS_SH} ./heredoc5.sub | |
139 | ||
4491c030 CR |
140 | # test $'...' and $"..." quoted strings in here-documents |
141 | ${THIS_SH} ./heredoc6.sub | |
142 | ||
143 | # interaction between here-documents and command substitutions | |
144 | ${THIS_SH} ./heredoc7.sub | |
145 | ||
146 | ||
0001803f CR |
147 | echo $( |
148 | cat <<< "comsub here-string" | |
149 | ) | |
150 | ||
ccc6cda3 JA |
151 | # check that end of file delimits a here-document |
152 | # THIS MUST BE LAST! | |
153 | ||
154 | cat << EOF | |
155 | hi | |
156 | there |