Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Quotes are preserved with environment variables #77

Open
kylegibson opened this issue Nov 15, 2022 · 1 comment
Open

Quotes are preserved with environment variables #77

kylegibson opened this issue Nov 15, 2022 · 1 comment

Comments

@kylegibson
Copy link

A .env file with spaces can't be sourced unless the values are quoted, but then the quotes are preserved in the rendered output, but not preserved in the shell:

$ cat test.env
FOO="one two three"

$ source test.env
$ echo $FOO
one two three

$ cat test.conf 
BAR = {{ FOO }}

$ j2 test.conf test.env 
BAR = "one two three"

If I change test.env to remove the quotes, then sourcing no longer works:

$ cat test.env
FOO=one two three

$ j2 test.conf test.env
BAR = one two three

$ source test.env
Command 'two' not found, did you mean:
...

How can I create a .env with values that have spaces that is consistent between the shell and the j2 output?

@kylegibson
Copy link
Author

Temporary workaround:

$ cat test.conf 
BAR = {{ FOO.strip('"') }}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant