mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Mechanism to dynamically add HOMEBREW.* vars to 'env -i' command string in 'bin/brew'
This commit is contained in:
parent
adc43466a6
commit
5d1576784a
11
Library/Homebrew/utils/homebrew_vars.rb
Executable file
11
Library/Homebrew/utils/homebrew_vars.rb
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
ENV.keys.each do |key|
|
||||
if key =~ /^HOMEBREW.*/
|
||||
# Remove any HOMEBREW.* vars containing white-space which causes a problem for "env -i" command via string.
|
||||
#
|
||||
# (Any user supplied HOMEBREW.* vars with valid white-space need to be hard-coded in 'bin/brew')
|
||||
#
|
||||
puts "#{key}=#{ENV[key]}" unless ENV[key].split(' ').length > 1
|
||||
end
|
||||
end
|
23
bin/brew
23
bin/brew
@ -46,15 +46,22 @@ HOMEBREW_LIBRARY="$HOMEBREW_REPOSITORY/Library"
|
||||
|
||||
if [[ -n "$HOMEBREW_ENV_FILTERING" ]]
|
||||
then
|
||||
env -i \
|
||||
HOME="$HOME" \
|
||||
|
||||
homebrew_vars=$("$HOMEBREW_LIBRARY/Homebrew/utils/homebrew_vars.rb")
|
||||
|
||||
cmd_str="/usr/bin/env -i \
|
||||
HOME=$HOME \
|
||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin \
|
||||
TERM="$TERM" \
|
||||
HOMEBREW_BREW_FILE="$HOMEBREW_BREW_FILE" \
|
||||
HOMEBREW_PREFIX="$HOMEBREW_PREFIX" \
|
||||
HOMEBREW_REPOSITORY="$HOMEBREW_REPOSITORY" \
|
||||
HOMEBREW_LIBRARY="$HOMEBREW_LIBRARY" \
|
||||
/bin/bash "$HOMEBREW_LIBRARY/Homebrew/brew.sh" "$@"
|
||||
TERM=$TERM \
|
||||
HOMEBREW_BREW_FILE=$HOMEBREW_BREW_FILE \
|
||||
HOMEBREW_PREFIX=$HOMEBREW_PREFIX \
|
||||
HOMEBREW_REPOSITORY=$HOMEBREW_REPOSITORY \
|
||||
HOMEBREW_LIBRARY=$HOMEBREW_LIBRARY \
|
||||
$homebrew_vars \
|
||||
/bin/bash $HOMEBREW_LIBRARY/Homebrew/brew.sh $@"
|
||||
|
||||
command $cmd_str
|
||||
|
||||
else
|
||||
source "$HOMEBREW_LIBRARY/Homebrew/brew.sh"
|
||||
fi
|
||||
|
Loading…
x
Reference in New Issue
Block a user