Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The parser includes the interpolation expression in the value even if the variable is unset #34

Closed
k3ndo opened this issue Feb 12, 2022 · 0 comments
Labels
behavior change Change behavior of a function
Milestone

Comments

@k3ndo
Copy link
Contributor

k3ndo commented Feb 12, 2022

Given the following code:

new EnvLoader()
       .IgnoreParserException()
       .Load();

Console.WriteLine(Environment.GetEnvironmentVariable("CS")); // Output: server=${MYSQL_HOST};user=root${ };

And:

CS = server=${MYSQL_HOST};user=root${ };

The parser is including the expression "${MYSQL_HOST}" in the value, this really doesn't make sense because it doesn't contribute anything. If the parser can't expand the interpolated variable, then don't include anything in the value.

I expect such an output:

server=;user=root;

Well, I think this output makes more sense than the previous one because the parser does not have to include the interpolation expression inside the value in case the variable is unset, why would it do so if it did not find it?

This is not a bug, it would just be nice if this parser behavior could be changed.

I will do a PR to change this.

@k3ndo k3ndo mentioned this issue Feb 12, 2022
@MrDave1999 MrDave1999 added the behavior change Change behavior of a function label Feb 12, 2022
MrDave1999 pushed a commit that referenced this issue Feb 17, 2022
@MrDave1999 MrDave1999 added this to the 8.0.0 milestone Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
behavior change Change behavior of a function
Projects
None yet
Development

No branches or pull requests

2 participants