mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Support for zsh ZDOTDIR, FIX #6533
- Add test spec with ZDOTDIR set and unset
This commit is contained in:
parent
fd9a09e18f
commit
960b8b659c
@ -19,8 +19,15 @@ describe Utils::Shell do
|
|||||||
expect(subject.profile).to eq("~/.bash_profile")
|
expect(subject.profile).to eq("~/.bash_profile")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns /tmp/.zshrc for Zsh if ZDOTDIR is /tmp" do
|
||||||
|
ENV["SHELL"] = "/bin/zsh"
|
||||||
|
ENV["ZDOTDIR"] = "/tmp"
|
||||||
|
expect(subject.profile).to eq("/tmp/.zshrc")
|
||||||
|
end
|
||||||
|
|
||||||
it "returns ~/.zshrc for Zsh" do
|
it "returns ~/.zshrc for Zsh" do
|
||||||
ENV["SHELL"] = "/bin/zsh"
|
ENV["SHELL"] = "/bin/zsh"
|
||||||
|
ENV["ZDOTDIR"] = nil
|
||||||
expect(subject.profile).to eq("~/.zshrc")
|
expect(subject.profile).to eq("~/.zshrc")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ module Utils
|
|||||||
|
|
||||||
# return the shell profile file based on user's preferred shell
|
# return the shell profile file based on user's preferred shell
|
||||||
def profile
|
def profile
|
||||||
|
return ENV.fetch("ZDOTDIR", "~") + "/.zshrc" if preferred.eql? "zsh"
|
||||||
SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
|
SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user