Skip to content

Parser does not support trailing comments #141

@OlegSmelov

Description

@OlegSmelov

For .env, we use the following pattern:

export KEY="value" # comment

Actual behavior after we parse such file:

>>> os.getenv('KEY')
'"value" # comment'

Expected behavior:

>>> os.getenv('KEY')
'value'

The tricky part here is that # can be contained within the quoted value (e.g. KEY="#"), so we can't ignore everything after the #.

What is worse, bash requires # to be at the beginning of the token, so something like this is valid:

bash$ KEY=#value
bash$ echo $KEY
#value

Ruby dotenv works fine with trailing comments, but it uses a complicated regular expression to do that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions