]>
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 | # | |
a0c0a00f | 14 | SAVEPWD=$PWD |
d233b485 | 15 | : ${TMPDIR:=/tmp} |
a0c0a00f CR |
16 | cd $TMPDIR || echo "heredoc3.sub: cannot cd to $TMPDIR" >&2 |
17 | ||
ac50fbac CR |
18 | text=$(cat <<EOF |
19 | here is the text | |
20 | EOF) | |
21 | ||
22 | echo = $text = | |
23 | ||
24 | unbalanced=$(cat <<EOF | |
25 | this paren ) is not a problem | |
26 | EOF) | |
27 | ||
28 | echo $unbalanced | |
29 | ||
30 | balanced=$(cat <<EOF | |
31 | these balanced parens ( ) are not a problem | |
32 | EOF) | |
33 | ||
34 | echo $balanced | |
35 | ||
36 | balanced=$(cat <<EOF | |
37 | quoted balanced parens \( ) are not a problem either | |
38 | EOF) | |
39 | ||
40 | echo $balanced | |
41 | ||
42 | (cat <<EOF | |
43 | more text in a subshell | |
44 | EOF | |
45 | ) | |
46 | ||
47 | (cat <<EOF; ) | |
48 | some more text in a different subshell | |
49 | EOF | |
50 | echo end | |
51 | ||
52 | # semi-weird examples posted by Wayne Pollack to austin-group mailing list | |
53 | cat <<-' END' | |
54 | hello | |
55 | END | |
56 | ||
57 | cat <<END | |
58 | hello | |
59 | END\ | |
60 | END | |
61 | END | |
62 | echo end ENDEND | |
63 | ||
64 | cat <<' END ' | |
65 | hello | |
66 | END | |
67 | echo end hello | |
68 | ||
a0c0a00f | 69 | cat <<x*x >/dev/null & touch 'x*x' |
ac50fbac CR |
70 | x star x |
71 | x*x | |
a0c0a00f | 72 | wait $! |
ac50fbac CR |
73 | echo end 'x*x' |
74 | rm 'x*x' | |
75 | ||
76 | cat <<END | |
77 | hello\ | |
78 | END | |
79 | END | |
80 | echo end helloEND | |
81 | ||
82 | cat <<END | |
83 | hello | |
84 | \END | |
85 | END | |
d233b485 CR |
86 | echo -E end 'hello<NL>\END' |
87 | ||
88 | # gprof | |
89 | if [ -n "$GMON_OUT_PREFIX" ]; then | |
90 | mv ${GMON_OUT_PREFIX}.[0-9]* "$SAVEPWD" >/dev/null 2>&1 | |
91 | fi | |
92 | cd "$SAVEPWD" | |
ac50fbac CR |
93 | |
94 | # this has to be last -- results in a syntax error | |
95 | # doesn't currently parse because EOF is not on a line by itself -- should it? | |
96 | (cat <<EOF | |
97 | still more text in a subshell | |
98 | EOF) |