[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reportting a BUG in Heredoc
From: |
Kerin Millar |
Subject: |
Re: Reportting a BUG in Heredoc |
Date: |
Tue, 25 Oct 2022 23:58:41 +0100 |
On Tue, 25 Oct 2022 19:32:33 +0000
Abla OUHAGA <Abla.OUHAGA@um6p.ma> wrote:
> From: abouhaga
> To: bug-bash@gnu.org
> Subject: Reporting a BUG in Heredoc.
>
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: darwin18.7.0
> Compiler: clang
> Compilation CFLAGS: -DSSH_SOURCE_BASHRC
> uname output: Darwin e2r9p9.1337.ma 18.7.0 Darwin Kernel Version 18.7.0: Tue
> Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
> Machine Type: x86_64-apple-darwin18.7.0
>
> Bash Version: 5.2
> Patch Level: 2
> Release Status: release
>
> Description:
> While working to make my own shell that reproduces the behavior of
> bash for some cases, I tested my work and compared it to the output of Bash.
> For Heredoc I gave it different delimiters as test cases, then I encountered
> a Bug for the case of ( << "$USER ) as input.
>
> Repeat-By:
> For the described case above, the heredoc never gets out with any
> given delimiter. I do understand that I should close the double quote first
> in order to get in the heredoc maybe, But I find it ambiguous. I spent hours
> trying so many delimiters but it never gets out of it unless I enter CTRL+D
> (EOF). I also upgraded my BASH to check if it's the same behavior in the
> latest version, and I encounter the same BUG. based on that I did not know
> how to implement this test case in my own shell. Finally, that is my reason
> for reporting it.
> Thank you.
>
> Fix:
> I guess that the correct behavior is to give a prompt to close the
> double quote, then proceed to close the heredoc with an unquoted delimiter.
>
> PS: It is the case for a single quote too.
Below is a test case that concretely demonstrates the issue. The warning
implies that the delimiter is correctly taken to be $'EOF\n', yet bash does not
recognise the delimiter at the point that it occurs.
$ printf '%s\n' 'cat <<"EOF' '"' line EOF '' | bash
bash: line 5: warning: here-document at line 2 delimited by end-of-file (wanted
`EOF
')
line
EOF
$
For comparative purposes, I tried dash-0.5.11.5, ksh-2020 and busybox-1.34.1
(ash), all of which appear to get it right.
$ printf '%s\n' 'cat <<"EOF' '"' line EOF '' | dash
line
$
$ printf '%s\n' 'cat <<"EOF' '"' line EOF '' | ksh
line
$
$ printf '%s\n' 'cat <<"EOF' '"' line EOF '' | busybox sh
line
$
--
Kerin Millar