diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:33:23 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:33:23 +0000 |
commit | 1d5cace9db9aef76f26b2d7ba54bbb76443b00b2 (patch) | |
tree | 314a15dd1aa103da13bdc83ba1d2105a290bc5ba /tests/heredoc.tests | |
parent | Initial commit. (diff) | |
download | bash-1d5cace9db9aef76f26b2d7ba54bbb76443b00b2.tar.xz bash-1d5cace9db9aef76f26b2d7ba54bbb76443b00b2.zip |
Adding upstream version 5.0.upstream/5.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/heredoc.tests')
-rw-r--r-- | tests/heredoc.tests | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/heredoc.tests b/tests/heredoc.tests new file mode 100644 index 0000000..303949f --- /dev/null +++ b/tests/heredoc.tests @@ -0,0 +1,105 @@ +# check order and content of multiple here docs + +cat << EOF1 << EOF2 +hi +EOF1 +there +EOF2 + +while read line1; do + read line2 <&3 + echo $line1 - $line2 +done <<EOF1 3<<EOF2 +one +two +three +EOF1 +alpha +beta +gamma +EOF2 + + +# check quoted here-doc is protected + +a=foo +cat << 'EOF' +hi\ +there$a +stuff +EOF + +# check that quoted here-documents don't have \newline processing done + +cat << 'EOF' +hi\ +there +EO\ +F +EOF +true + +# check that \newline is removed at start of here-doc +cat << EO\ +F +hi +EOF + +# check that \newline removal works for here-doc delimiter +cat << EOF +hi +EO\ +F + +# check operation of tab removal in here documents +cat <<- EOF + tab 1 + tab 2 + tab 3 + EOF + +# check appending of text to file from here document +rm -f ${TMPDIR}/bash-zzz +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 <<ENDOFINPUT >/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 + +echo $( + cat <<< "comsub here-string" +) + +# check that end of file delimits a here-document +# THIS MUST BE LAST! + +cat << EOF +hi +there |