]>
Commit | Line | Data |
---|---|---|
ccc6cda3 JA |
1 | # check order and content of multiple here docs |
2 | ||
3 | cat << EOF1 << EOF2 | |
4 | hi | |
5 | EOF1 | |
6 | there | |
7 | EOF2 | |
8 | ||
d166f048 JA |
9 | while read line1; do |
10 | read line2 <&3 | |
11 | echo $line1 - $line2 | |
12 | done <<EOF1 3<<EOF2 | |
13 | one | |
14 | two | |
15 | three | |
16 | EOF1 | |
17 | alpha | |
18 | beta | |
19 | gamma | |
20 | EOF2 | |
21 | ||
22 | ||
ccc6cda3 JA |
23 | # check quoted here-doc is protected |
24 | ||
25 | a=foo | |
26 | cat << 'EOF' | |
27 | hi\ | |
28 | there$a | |
29 | stuff | |
30 | EOF | |
31 | ||
32 | # check that quoted here-documents don't have \newline processing done | |
33 | ||
34 | cat << 'EOF' | |
35 | hi\ | |
36 | there | |
37 | EO\ | |
38 | F | |
39 | EOF | |
40 | true | |
41 | ||
42 | # check that \newline is removed at start of here-doc | |
43 | cat << EO\ | |
44 | F | |
45 | hi | |
46 | EOF | |
47 | ||
48 | # check that \newline removal works for here-doc delimiter | |
49 | cat << EOF | |
50 | hi | |
51 | EO\ | |
52 | F | |
53 | ||
d166f048 JA |
54 | # check operation of tab removal in here documents |
55 | cat <<- EOF | |
56 | tab 1 | |
57 | tab 2 | |
58 | tab 3 | |
59 | EOF | |
60 | ||
61 | # check appending of text to file from here document | |
d233b485 CR |
62 | rm -f ${TMPDIR}/bash-zzz |
63 | cat > ${TMPDIR}/bash-zzz << EOF | |
d166f048 JA |
64 | abc |
65 | EOF | |
d233b485 | 66 | cat >> ${TMPDIR}/bash-zzz << EOF |
d166f048 JA |
67 | def ghi |
68 | jkl mno | |
69 | EOF | |
d233b485 CR |
70 | cat ${TMPDIR}/bash-zzz |
71 | rm -f ${TMPDIR}/bash-zzz | |
d166f048 JA |
72 | |
73 | # make sure command printing puts the here-document as the last redirection | |
74 | # on the line, and the function export code preserves syntactic correctness | |
75 | fff() | |
76 | { | |
d233b485 | 77 | ed ${TMPDIR}/foo <<ENDOFINPUT >/dev/null |
d166f048 JA |
78 | /^name/d |
79 | w | |
80 | q | |
81 | ENDOFINPUT | |
82 | aa=1 | |
83 | } | |
84 | ||
85 | type fff | |
86 | export -f fff | |
87 | ${THIS_SH} -c 'type fff' | |
88 | ||
17345e5a JA |
89 | ${THIS_SH} ./heredoc1.sub |
90 | ||
ac50fbac CR |
91 | # test heredocs in command substitutions |
92 | ${THIS_SH} ./heredoc2.sub | |
ac50fbac | 93 | ${THIS_SH} ./heredoc3.sub |
d233b485 | 94 | ${THIS_SH} ./heredoc4.sub |
ac50fbac | 95 | |
0001803f CR |
96 | echo $( |
97 | cat <<< "comsub here-string" | |
98 | ) | |
99 | ||
ccc6cda3 JA |
100 | # check that end of file delimits a here-document |
101 | # THIS MUST BE LAST! | |
102 | ||
103 | cat << EOF | |
104 | hi | |
105 | there |