heredoc9.0 revision 302408
164562Sgshapiro# $FreeBSD: stable/11/bin/sh/tests/parser/heredoc9.0 221887 2011-05-14 14:19:30Z jilles $ 264562Sgshapiro 3261363Sgshapiro# It may be argued that 464562Sgshapiro# x=$(cat <<EOF 564562Sgshapiro# foo 664562Sgshapiro# EOF) 764562Sgshapiro# is a valid complete command that sets x to foo, because 864562Sgshapiro# cat <<EOF 964562Sgshapiro# foo 1064562Sgshapiro# EOF 1164562Sgshapiro# is a valid script even without the final newline. 1264562Sgshapiro# However, if the here-document is not within a new-style command substitution 13266692Sgshapiro# or there are other constructs nested inside the command substitution that 1464562Sgshapiro# need terminators, the delimiter at the start of a line followed by a close 1564562Sgshapiro# parenthesis is clearly a literal part of the here-document. 1664562Sgshapiro 1764562Sgshapiro# This file contains tests that also work with simplistic $(...) parsers. 18 19failures=0 20 21check() { 22 if ! eval "[ $* ]"; then 23 echo "Failed: $*" 24 : $((failures += 1)) 25 fi 26} 27 28check '`${SH} -c "cat <<EOF 29EOF) 30EOF 31"` = "EOF)"' 32 33check '`${SH} -c "(cat <<EOF 34EOF) 35EOF 36)"` = "EOF)"' 37 38check '"`cat <<EOF 39EOF x 40EOF 41`" = "EOF x"' 42 43check '"`cat <<EOF 44EOF ) 45EOF 46`" = "EOF )"' 47 48check '"`cat <<EOF 49EOF) 50EOF 51`" = "EOF)"' 52 53check '"$(cat <<EOF 54EOF x 55EOF 56)" = "EOF x"' 57 58exit $((failures != 0)) 59