From 566f7f4555dcde26252a0db01f6bd28f6bb00494 Mon Sep 17 00:00:00 2001
From: Kenneth Reitz <me@kennethreitz.com>
Date: Tue, 21 Jan 2014 17:47:05 -0500
Subject: [PATCH] new buildpack env standard

---
 bin/compile |  2 +-
 bin/utils   | 24 ++++++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/bin/compile b/bin/compile
index 9bad3a28..a086861b 100755
--- a/bin/compile
+++ b/bin/compile
@@ -15,7 +15,7 @@ BIN_DIR=$(cd $(dirname $0); pwd) # absolute path
 ROOT_DIR=$(dirname $BIN_DIR)
 BUILD_DIR=$1
 CACHE_DIR=$2
-ENV_FILE=$3
+ENV_DIR=$3
 
 
 CACHED_DIRS=".heroku"
diff --git a/bin/utils b/bin/utils
index 68608148..a8af9fbf 100755
--- a/bin/utils
+++ b/bin/utils
@@ -59,10 +59,22 @@ function deep-rm (){
   find -H $1 -maxdepth 1 -name '.*' -a \( -type d -o -type f -o -type l \) -exec rm -fr '{}' \;
 }
 
-function sub-env (){
-  if [[ -f $ENV_FILE ]]; then
-    (export $(egrep -v '^(GIT_DIR|PYTHONHOME|PYTHONPATH|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)' -f $ENV_FILE); $1)
-  else
+
+sub-env() {
+
+  WHITELIST=${2:-''}
+  BLACKLIST=${3:-'^(GIT_DIR|PYTHONHOME|PYTHONPATH|LD_LIBRARY_PATH|LIBRARY_PATH|PATH)$'}
+
+  (
+    if [ -d "$ENV_DIR" ]; then
+      for e in $(ls $ENV_DIR); do
+        echo "$e" | grep -E "$WHITELIST" | grep -qvE "$BLACKLIST" &&
+        export "$e=$(cat $ENV_DIR/$e)"
+        :
+      done
+    fi
+
     $1
-  fi
-}
+
+  )
+}
\ No newline at end of file
-- 
GitLab