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