Skip to content

Commit

Permalink
Merge pull request #1753 from doughazell/filter_all_env_vars_932
Browse files Browse the repository at this point in the history
Suggested solution for 'Filter all environment variables by default #932' issue
  • Loading branch information
MikeMcQuaid authored Feb 27, 2017
2 parents 3d0d5d6 + c2a460e commit ef85460
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion bin/brew
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,17 @@ fi

HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"

source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
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"
fi

0 comments on commit ef85460

Please sign in to comment.