colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Weird acceptation of here document #114

Open Niols opened 4 years ago

Niols commented 4 years ago

Consider the following here document:

cat <<EOF
a `b' c
d `e' f `g' h
EOF

Dash refuses it. I think it is probably the right thing to do. Morbig's parsing is quite weird anyway here:

[
    "Word",
    "a `b' c\nd `e' f `g' h\n",
    [
    [ "WordLiteral", "a " ],
    [
        "WordSubshell",
        [ "SubShellKindBackQuote" ],
        [
        [...]

                "SimpleCommand_CmdName_CmdSuffix",
                [
            "CmdName_Word",
            [
            "Word",
            "b' c\nd `e'",
            [
                [ "WordLiteral", "b" ],
                [
                "WordSingleQuoted",
                [
                    "Word",
                    " c\nd `e",
                    [
                    [
                        "WordLiteral",
                        " c\nd `e"
                    ]
                    ]
                ]
                ]
            ]
            ]
        ],
        [
            "CmdSuffix_Word",
            [
            "Word",
            "f",
            [ [ "WordName", "f" ] ]
            ]
        ]
        ]
    ],
    [ "WordLiteral", "g' h\n" ]
    ]
]

How can g' h be a literal?