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

Handle multiline strings in .env file #128

Closed
joshfriend opened this issue Jan 19, 2015 · 6 comments
Closed

Handle multiline strings in .env file #128

joshfriend opened this issue Jan 19, 2015 · 6 comments

Comments

@joshfriend
Copy link

see ddollar/foreman#250

Very useful for working with keys/certs loaded from environment variables.

@nickstenning
Copy link
Owner

Honcho has supported this since v0.5.0:

.env:

FOO="hello\nworld"

Procfile:

foo: echo $FOO

honcho output:

$ honcho start
23:59:49 system | foo.1 started (pid=74396)
23:59:49 foo.1  | hello
23:59:49 foo.1  | there
23:59:49 system | foo.1 stopped (rc=0)

@joshfriend
Copy link
Author

@nickstenning I did some testing, and the multiline string handling does not correctly match that of Foreman:

test.procfile:

print: python -c "import os; print os.getenv('FOO')"

test.env:

FOO="hello\nworld"

Output from honcho==0.6.5:

$ honcho start print -f test.procfile -e test.env
10:19:51 system  | print.1 started (pid=15473)
10:19:51 print.1 | hello\nworld
10:19:51 system  | print.1 stopped (rc=0)

Ouptut from foreman:

$ foreman start print -f test.procfile -e test.env
10:30:59 print.1 | started with pid 17302
10:30:59 print.1 | hello
10:30:59 print.1 | world
10:30:59 print.1 | exited with code 0
10:30:59 system  | sending SIGTERM to all processes
SIGTERM received

I've re-opened #129 which should fix this.

@nickstenning
Copy link
Owner

Thanks for this. This is a regression in v0.6.5 introduced by the well-intentioned changes of 08063ea. I'll look into it.

@nickstenning nickstenning reopened this Mar 9, 2015
@joshfriend
Copy link
Author

Thanks, I've updated the PR since there were conflicts.

@nickstenning
Copy link
Owner

Ugh. Python 3 removed the bytestring-to-bytestring decoders that I used to fix this in 920b0b0. Watch this space...

@nickstenning nickstenning reopened this Mar 10, 2015
nickstenning added a commit that referenced this issue Mar 16, 2015
Holy mother of God. Making string_escape work across Python 2 and 3 is
an absolute nightmare. The bytes-to-bytes encodes were removed in Python
3, so the only way to use them is to use unicode_escape directly from
the codecs package, but this makes a complete hash of the task if you
give it unicode:

    >>> codecs.decode('åéïò', 'unicode_escape')
    'åéïò'
    >>> codecs.decode('åéïò'.encode('utf8'), 'unicode_escape')
    'åéïò'

WTF!? Anyway. Life is too short. This will make the tests pass.

Fixes #128.
@joshfriend
Copy link
Author

Life is too short. This will make the tests pass.

😆

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

No branches or pull requests

2 participants