Merge pull request #1753 from doughazell/filter_all_env_vars_932

Suggested solution for 'Filter all environment variables by default #932' issue
This commit is contained in:
Mike McQuaid 2017-02-27 08:39:32 +00:00 committed by GitHub
commit ef85460c52

View File

@ -44,4 +44,17 @@ fi
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library" HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
if [[ -n "$HOMEBREW_ENV_FILTERING" ]]
then
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
FILTERED_ENV=()
for VAR in HOME SHELL PATH TERM LOGNAME USER "${!HOMEBREW_@}"
do
FILTERED_ENV+=( "${VAR}=${!VAR}" )
done
/usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash "$HOMEBREW_LIBRARY/Homebrew/brew.sh" "$@"
else
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh" source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
fi