colis-anr / morbig

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

Weird parsing of parameters with special characters in them. #95

Closed Niols closed 5 years ago

Niols commented 5 years ago

The following:

heredoc="${arg#<<?}"

is parsed as (here is a part of the JSON):

[
    "CmdPrefix_AssignmentWord",
    [
        [ "Name", "heredoc" ],
        [
            "Word",
            "\"${arg#<<}?}\"",
            [
                [
                    "WordDoubleQuoted",
                    [
                        "Word",
                        "${arg#<<}?}",
                        [
                            [
                                "WordVariable",
                                [
                                    "VariableAtom",
                                    "arg",
                                    [
                    "RemoveSmallestPrefixPattern",
                    [
                                            "Word",
                                            "<<",
                                            [ [ "WordLiteral", "<<" ] ]
                    ]
                                    ]
                                ]
                            ],
                            [ "WordLiteral", "?}" ]
                        ]
                    ]
                ]
            ]
        ]
    ]
]

which is rather weird.

yurug commented 5 years ago

Fixed by 8683140