Skip to content

Instantly share code, notes, and snippets.

@jbayer
Created April 30, 2014 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbayer/3f6d31f06dcb26f7c325 to your computer and use it in GitHub Desktop.
Save jbayer/3f6d31f06dcb26f7c325 to your computer and use it in GitHub Desktop.
Bash function demonstrating how to export the content of the buildpack compile script ENV_DIR into the environment from heroku docs
export_env_dir() {
env_dir=$1
whitelist_regex=${2:-''}
blacklist_regex=${3:-'^(PATH|GIT_DIR|CPATH|CPPATH|LD_PRELOAD|LIBRARY_PATH)$'}
if [ -d "$env_dir" ]; then
for e in $(ls $env_dir); do
echo "$e" | grep -E "$whitelist_regex" | grep -qvE "$blacklist_regex" &&
export "$e=$(cat $env_dir/$e)"
:
done
fi
}
@nebhale
Copy link

nebhale commented Apr 30, 2014

Will this be encapsulated into a library and version controlled to ensure that all buildpacks do this consistently?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment