1
0
mirror of /repos/baseimage-docker.git synced 2025-12-30 08:01:31 +01:00

Merge pull request #49 from harto/trim-env-newlines

Trim trailing newlines from file-based envs
This commit is contained in:
Hongli Lai 2014-04-02 16:47:09 +02:00
commit c740ff2f4d

View File

@ -59,7 +59,10 @@ def import_envvars(clear_existing_environment = True):
for envfile in listdir("/etc/container_environment"):
name = os.path.basename(envfile)
with open("/etc/container_environment/" + envfile, "r") as f:
value = f.read()
# Text files often end with a trailing newline, which we
# don't want to include in the env variable value. See
# https://github.com/phusion/baseimage-docker/pull/49
value = re.sub('\n\Z', '', f.read())
new_env[name] = value
if clear_existing_environment:
os.environ.clear()