ash: [PARSER] Recognise here-doc delimiters terminated by EOF
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 26 Oct 2016 14:26:45 +0000 (16:26 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 26 Oct 2016 14:26:45 +0000 (16:26 +0200)
commit350e686f3b04f41f623316706094f0e18a10c1cf
tree721ff03c6f5538060cc91f5c03bb9047c354970c
parentf15aa57a7f5edcbf3098873b8798c0ea7f496ed7
ash: [PARSER] Recognise here-doc delimiters terminated by EOF

Upstream commit 1:

    Date: Wed, 26 Sep 2007 17:14:16 +0800
    [PARSER] Recognise here-doc delimiters terminated by EOF

    Previously dash required a <newline> character to be present in order for
    a here-document delimiter to be detected.  Allowing EOF in the absence of
    a <newline> to play the same purpose allows some intuitive scripts to
    succeed.  POSIX seems to be silence on this so this should be OK.

    Test case:

        eval 'cat <<- NOT
                test
        NOT'
        echo OK

    Old result:

        test
        NOTOK

    New result:

        test
        OK

Upstream commit 2:

    Date: Sat, 20 Oct 2007 18:49:31 +0800
    [PARSER] Fix here-doc corruption

    The change

        [PARSER] Recognise here-doc delimiters terminated by EOF

    introduced a regerssion whereby lines starting with eofmark but are not equal
    to eofmark would be corrupted.  This patch fixes it.

    Test case:

        cat << _ACEOF
        _ASBOX
        _ACEOF

    Old result:

        SASBOX

    New result:

        _ASBOX

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
shell/ash.c
shell/ash_test/ash-heredoc/heredoc6.right [new file with mode: 0644]
shell/ash_test/ash-heredoc/heredoc6.tests [new file with mode: 0755]
shell/ash_test/ash-heredoc/heredoc7.right [new file with mode: 0644]
shell/ash_test/ash-heredoc/heredoc7.tests [new file with mode: 0755]
shell/hush_test/hush-heredoc/heredoc6.right [new file with mode: 0644]
shell/hush_test/hush-heredoc/heredoc6.tests [new file with mode: 0755]
shell/hush_test/hush-heredoc/heredoc7.right [new file with mode: 0644]
shell/hush_test/hush-heredoc/heredoc7.tests [new file with mode: 0755]