From 6c20c8ed2cb9ab69a1a57ccb2b9b79969a808321 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 17:38:56 +0200 Subject: Adding upstream version 5.2.15. Signed-off-by: Daniel Baumann --- tests/heredoc.tests | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 tests/heredoc.tests (limited to 'tests/heredoc.tests') diff --git a/tests/heredoc.tests b/tests/heredoc.tests new file mode 100644 index 0000000..d10a7c1 --- /dev/null +++ b/tests/heredoc.tests @@ -0,0 +1,156 @@ +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# basics +cat < ${TMPDIR}/bash-zzz << EOF +abc +EOF +cat >> ${TMPDIR}/bash-zzz << EOF +def ghi +jkl mno +EOF +cat ${TMPDIR}/bash-zzz +rm -f ${TMPDIR}/bash-zzz + +# make sure command printing puts the here-document as the last redirection +# on the line, and the function export code preserves syntactic correctness +fff() +{ + ed ${TMPDIR}/foo </dev/null +/^name/d +w +q +ENDOFINPUT +aa=1 +} + +type fff +export -f fff +${THIS_SH} -c 'type fff' + +${THIS_SH} ./heredoc1.sub + +# test heredocs in command substitutions +${THIS_SH} ./heredoc2.sub +${THIS_SH} ./heredoc3.sub +${THIS_SH} ./heredoc4.sub + +# heredoc tests that use different size documents to test pipe implementation +${THIS_SH} ./heredoc5.sub + +# test $'...' and $"..." quoted strings in here-documents +${THIS_SH} ./heredoc6.sub + +# interaction between here-documents and command substitutions +${THIS_SH} ./heredoc7.sub + + +echo $( + cat <<< "comsub here-string" +) + +# check that end of file delimits a here-document +# THIS MUST BE LAST! + +cat << EOF +hi +there -- cgit v1.2.3