-
Notifications
You must be signed in to change notification settings - Fork 489
Closed
Labels
Description
According to the documentation TEST="foo\nbar" should produce a multiline environment variable however I cannot get it to work, what am I doing wrong? I have tried every variation I can think of.
.env
TEST1="foo\nbar"
TEST2=foo\nbar
TEST3="foo
bar"
TEST4="foo\\nbar"
TEST5=foo\\nbar
TEST6=foo
bar
TEST7="foo\
bar"
TEST8=foo\
bar
test.py
import os
from os.path import join, dirname
from dotenv import load_dotenv
dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path, verbose=True)
tests = (
(key, value)
for key, value in os.environ.items()
if key.startswith('TEST'))
for key, value in tests:
print(key, value)
output
TEST1 foo\nbar
TEST2 foo\\nbar
TEST3 "foo
TEST4 foo\\nbar
TEST5 foo\\\\nbar
TEST6 foo
TEST7 "foo\\
TEST8 foo\\
Trying with "real" environment variables through bash:
$ export TEST="foo
bar"
$ python -c "import os; print(os.environ['TEST'])"
foo
bar
using
Darwin Kernel Version 15.6.0
Python 3.6.2
python-dotenv==0.7.1
austinburks, Negashev, jcassee, garethbjohnson, nickalto and 5 morearchenroot