tests(here-doc): ensure here docs work in many situations

This commit is contained in:
Khaïs COLIN 2025-04-28 16:35:22 +02:00
parent aeb5105d97
commit ab861fc5c0

86
test.sh
View file

@ -1473,4 +1473,90 @@ minishell: $VAR: ambiguous redirect
minishell: $VAR: ambiguous redirect minishell: $VAR: ambiguous redirect
EOF EOF
when_run <<"EOF" "here-documents limiter is not expanded"
export LIM=hello
cat << $LIM
hi
hello
goodbye
$LIM
<< $LIM
EOF
expecting <<"EOF"
hi
hello
goodbye
minishell: warning: here-document delimited by end-of-file (wanted `$LIM')
EOF
when_run <<EOF "heredoc does not execute commands"
cat << eof > bonjour
echo hello
cat bonjour
EOF
expecting <<"EOF"
minishell: warning: here-document delimited by end-of-file (wanted `eof')
EOF
when_run <<EOF "heredoc into another file"
cat << eof > bonjour
hello
there
eof
cat bonjour
EOF
expecting <<"EOF"
hello
there
EOF
when_run <<EOF "heredoc into another command"
cat << eof | rev
hello
there
eof
EOF
expecting <<"EOF"
olleh
ereht
EOF
when_run <<EOF "heredoc all alone"
<< eof
it's just me
by myself
i'm all alone ;.;
eof
EOF
expecting <<"EOF"
EOF
when_run <<EOF "TRIPLE SUMMON"
cat<<x<<y<<z
hello
x
there
y
hi
z
EOF
expecting <<EOF
hi
EOF
when_run <<EOF "TRIPLE SUMMON into unknown command"
qwertyuiop<<x<<y<<z
hello
x
there
y
hi
z
echo \$?
EOF
expecting <<EOF
minishell: qwertyuiop: command not found
127
EOF
finalize finalize