xref: /freebsd/bin/sh/tests/parser/heredoc1.0 (revision 4c9a0adad18263ec8725d9bfc5f560c6ad1da8bd)
1
2failures=0
3
4check() {
5	if ! eval "[ $* ]"; then
6		echo "Failed: $*"
7		: $((failures += 1))
8	fi
9}
10
11check '"$(cat <<EOF
12hi
13EOF
14)" = hi'
15
16check '"$(cat <<EOF
17${$+hi}
18EOF
19)" = hi'
20
21unset yy
22check '"$(cat <<EOF
23${yy-hi}
24EOF
25)" = hi'
26
27check '"$(cat <<EOF
28${$+hi
29there}
30EOF
31)" = "hi
32there"'
33
34check '"$(cat <<EOF
35$((1+1))
36EOF
37)" = 2'
38
39check '"$(cat <<EOF
40$(echo hi)
41EOF
42)" = hi'
43
44check '"$(cat <<EOF
45`echo hi`
46EOF
47)" = hi'
48
49check '"$(cat <<\EOF
50${$+hi}
51EOF
52)" = "\${\$+hi}"'
53
54check '"$(cat <<\EOF
55$(
56EOF
57)" = \$\('
58
59check '"$(cat <<\EOF
60`
61EOF
62)" = \`'
63
64check '"$(cat <<EOF
65"
66EOF
67)" = \"'
68
69check '"$(cat <<\EOF
70"
71EOF
72)" = \"'
73
74check '"$(cat <<esac
75'"'"'
76esac
77)" = "'"'"'"'
78
79check '"$(cat <<\)
80'"'"'
81)
82)" = "'"'"'"'
83
84exit $((failures != 0))
85