From 5b7a0eee31962e01614523baf7717932dbfe4ff4 Mon Sep 17 00:00:00 2001 From: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Date: Tue, 17 Aug 2021 11:43:19 +0300 Subject: [PATCH] Add HOMEBREW_SHELLENV_PREFIX env (#3908) --- images/linux/scripts/installers/homebrew.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/images/linux/scripts/installers/homebrew.sh b/images/linux/scripts/installers/homebrew.sh index 3c325b1b..5ff740aa 100644 --- a/images/linux/scripts/installers/homebrew.sh +++ b/images/linux/scripts/installers/homebrew.sh @@ -15,9 +15,10 @@ eval $(/home/linuxbrew/.linuxbrew/bin/brew shellenv) # Update /etc/environemnt ## Put HOMEBREW_* variables -brew shellenv|grep 'export HOMEBREW'|sed -E 's/^export (.*);$/\1/' | sudo tee -a /etc/environment +## The variable `HOMEBREW_SHELLENV_PREFIX` will be exported to avoid adding duplicate entries to the environment variables. +HOMEBREW_SHELLENV_PREFIX='' brew shellenv | grep 'export HOMEBREW'| sed -E 's/^export (.*);$/\1/' | sudo tee -a /etc/environment # add brew executables locations to PATH -brew_path=$(brew shellenv|grep '^export PATH' |sed -E 's/^export PATH="([^$]+)\$.*/\1/') +brew_path=$(HOMEBREW_SHELLENV_PREFIX='' brew shellenv | grep '^export PATH' | sed -E 's/^export PATH="([^$]+)\$.*/\1/') prependEtcEnvironmentPath "$brew_path" setEtcEnvironmentVariable HOMEBREW_NO_AUTO_UPDATE 1 setEtcEnvironmentVariable HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS 3650