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

Fix variable expansion order with override=False #287

Merged
merged 3 commits into from Dec 5, 2020

Conversation

bbc2
Copy link
Collaborator

@bbc2 bbc2 commented Nov 15, 2020

Closes #282

This is now done in two steps:

- Parse the value into a sequence of atoms (literal of variable).
- Resolve that sequence into a string.
This fixes an issue when a variable is resolved differently in two
bindings.

For instance, take the following env file:

```
PORT=8000
URL=http://localhost:${PORT}
```

With `PORT` set to `1234` in the environment, the environment resulting
from `dotenv_load(override=False)` would be:

```
PORT=1234
URL=http://localhost:8000
```

This was inconsistent and is fixed by this commit.  The environment
would now be:

```
PORT=1234
URL=http://localhost:1234
```

with override, and

```
PORT=8000
URL=http://localhost:8000
```

without override.

The behavior of `load_dotenv` is unchanged and always assumes
`override=True`.
@coveralls
Copy link

Coverage Status

Coverage decreased (-1.0%) to 88.309% when pulling 5a797e0 on bbc2:fix-variable-expansion-order into e13d957 on theskumar:master.

@bbc2 bbc2 merged commit 26ff5b7 into theskumar:master Dec 5, 2020
@bbc2 bbc2 deleted the fix-variable-expansion-order branch December 5, 2020 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistency in priorities of variable expansion
2 participants