#!/usr/bin/env python

import os
import json
import sys

for ups in json.loads(os.environ.get("VCAP_SERVICES", "{}")).get("user-provided", []):
    for k, v in ups.get("credentials", {}).items():
        sys.stdout.write("export %s='%s'\n" % (k, v.replace("'", "'\\''")))

@@ -214,17 +214,17 @@
 t.write(
-%22
+'
 export %25
@@ -229,44 +229,46 @@
  %25s=
-'%25s'%5Cn%22
+%22$(printf -- %25s)%22%5Cn'
  %25 (k, 
-v.
 rep
-lace(%22'%22, %22'%5C%5C''%22
+r(str(v)
 )))%0A

Fix newlines in UPS (#667)