Skip to content

Commit ef85460

Browse files
authored
Merge pull request #1753 from doughazell/filter_all_env_vars_932
Suggested solution for 'Filter all environment variables by default #932' issue
2 parents 3d0d5d6 + c2a460e commit ef85460

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

bin/brew

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,17 @@ fi
4444

4545
HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
4646

47-
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
47+
if [[ -n "$HOMEBREW_ENV_FILTERING" ]]
48+
then
49+
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
50+
51+
FILTERED_ENV=()
52+
for VAR in HOME SHELL PATH TERM LOGNAME USER "${!HOMEBREW_@}"
53+
do
54+
FILTERED_ENV+=( "${VAR}=${!VAR}" )
55+
done
56+
57+
/usr/bin/env -i "${FILTERED_ENV[@]}" /bin/bash "$HOMEBREW_LIBRARY/Homebrew/brew.sh" "$@"
58+
else
59+
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
60+
fi

0 commit comments

Comments
 (0)