From 4ac57d85b26d4cdb91aba8559afd35a184f7f2e4 Mon Sep 17 00:00:00 2001 From: Leo Heitmann Ruiz Date: Wed, 12 Jun 2024 16:24:45 +0200 Subject: [PATCH] Read ZDOTDIR environment variable --- Library/Homebrew/test/utils/shell_spec.rb | 4 ++-- Library/Homebrew/utils/shell.rb | 2 +- bin/brew | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/test/utils/shell_spec.rb b/Library/Homebrew/test/utils/shell_spec.rb index f3f2fb9bce742..16bb3670a3a5b 100644 --- a/Library/Homebrew/test/utils/shell_spec.rb +++ b/Library/Homebrew/test/utils/shell_spec.rb @@ -21,13 +21,13 @@ it "returns /tmp/.zshrc for Zsh if ZDOTDIR is /tmp" do ENV["SHELL"] = "/bin/zsh" - ENV["ZDOTDIR"] = "/tmp" + ENV["HOMEBREW_ZDOTDIR"] = "/tmp" expect(described_class.profile).to eq("/tmp/.zshrc") end it "returns ~/.zshrc for Zsh" do ENV["SHELL"] = "/bin/zsh" - ENV["ZDOTDIR"] = nil + ENV["HOMEBREW_ZDOTDIR"] = nil expect(described_class.profile).to eq("~/.zshrc") end diff --git a/Library/Homebrew/utils/shell.rb b/Library/Homebrew/utils/shell.rb index 186fc038e6828..d514f5914fd0c 100644 --- a/Library/Homebrew/utils/shell.rb +++ b/Library/Homebrew/utils/shell.rb @@ -60,7 +60,7 @@ def profile rc_profile = "#{Dir.home}/.rcrc" return rc_profile if File.exist? rc_profile when :zsh - return "#{ENV["ZDOTDIR"]}/.zshrc" if ENV["ZDOTDIR"].present? + return "#{ENV["HOMEBREW_ZDOTDIR"]}/.zshrc" if ENV["HOMEBREW_ZDOTDIR"].present? end SHELL_PROFILE_MAP.fetch(preferred, "~/.profile") diff --git a/bin/brew b/bin/brew index 91a687ec5571b..3d70018d67daa 100755 --- a/bin/brew +++ b/bin/brew @@ -180,6 +180,7 @@ USED_BY_HOMEBREW_VARS=( TMUX XDG_CACHE_HOME XDG_RUNTIME_DIR + ZDOTDIR ) for VAR in "${USED_BY_HOMEBREW_VARS[@]}" do