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

Parsing rules are somewhat unexpected #276

Closed
x-yuri opened this issue Sep 8, 2020 · 2 comments · Fixed by #277
Closed

Parsing rules are somewhat unexpected #276

x-yuri opened this issue Sep 8, 2020 · 2 comments · Fixed by #277
Assignees

Comments

@x-yuri
Copy link

x-yuri commented Sep 8, 2020

A=1 2 (one space) works, but A=1 2 (two spaces) produces an error. I've run into it with docker-compose:

.env:

A=1  2

docker-compose.yml:

version: '3'
services:
  app:
    image: alpine:3.12
    command: /app/1.sh
    env_file: .env
    volumes:
      - .:/app

1.sh:

#!/bin/sh -eux
set | grep ^A
$ docker-compose up -d && docker-compose logs -f
WARNING: Python-dotenv could not parse statement starting at line 1
WARNING: Python-dotenv could not parse statement starting at line 1
WARNING: Python-dotenv could not parse statement starting at line 1
WARNING: Python-dotenv could not parse statement starting at line 1
Creating network "overriding-vars_default" with the default driver
Creating overriding-vars_app_1 ... done
WARNING: Python-dotenv could not parse statement starting at line 1
WARNING: Python-dotenv could not parse statement starting at line 1
Attaching to overriding-vars_app_1
app_1  | + set
app_1  | + grep ^A
overriding-vars_app_1 exited with code 1

With A=1 2:

$ docker-compose up -d && docker-compose logs -f
Recreating overriding-vars_app_1 ... done
Attaching to overriding-vars_app_1
app_1  | + set
app_1  | + grep ^A
app_1  | A='1 2'
overriding-vars_app_1 exited with code 0

I'll provide a Python test case, if need be.

https://github.com/theskumar/python-dotenv/blob/v0.14.0/src/dotenv/parser.py#L175-L176

@x-yuri x-yuri changed the title Parser rules are somewhat unexpected Parsing rules are somewhat unexpected Sep 8, 2020
@bbc2
Copy link
Collaborator

bbc2 commented Sep 8, 2020

That's very interesting. Thank you for reporting. I'll look into it.

@bbc2
Copy link
Collaborator

bbc2 commented Sep 9, 2020

I think I've found a fix for the bug you reported. Could you let me know if the fix in #277 works for you?

@bbc2 bbc2 closed this as completed in #277 Sep 23, 2020
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 a pull request may close this issue.

2 participants