mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
bin/brew: tighten check in export_homebrew_env_file
The current glob check will accept lines like HOMEBREW_FOO=bar BAD_ENV_VAR=baz and happily export them, but we don't want that. Let's tighten up the check to reject lines like the above.
This commit is contained in:
parent
f82945ffa0
commit
4a11e74307
6
bin/brew
6
bin/brew
@ -108,14 +108,14 @@ HOMEBREW_LIBRARY="${HOMEBREW_REPOSITORY}/Library"
|
||||
|
||||
# Load Homebrew's variable configuration files from disk.
|
||||
export_homebrew_env_file() {
|
||||
local env_file
|
||||
local env_file="${1}"
|
||||
local homebrew_env_regex="^HOMEBREW_[A-Z_]+=[^=]*$"
|
||||
|
||||
env_file="${1}"
|
||||
[[ -r "${env_file}" ]] || return 0
|
||||
while read -r line
|
||||
do
|
||||
# only load HOMEBREW_* lines
|
||||
[[ "${line}" = "HOMEBREW_"* ]] || continue
|
||||
[[ "${line}" =~ ${homebrew_env_regex} ]] || continue
|
||||
export "${line?}"
|
||||
done <"${env_file}"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user