Skip to content

Commit

Permalink
Support for zsh ZDOTDIR, FIX Homebrew#6533
Browse files Browse the repository at this point in the history
- Add test spec with ZDOTDIR set and unset
  • Loading branch information
davidosomething committed Oct 6, 2019
1 parent fd9a09e commit 960b8b6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Library/Homebrew/test/utils/shell_spec.rb
Expand Up @@ -19,8 +19,15 @@
expect(subject.profile).to eq("~/.bash_profile")
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
ENV["SHELL"] = "/bin/zsh"
ENV["ZDOTDIR"] = nil
expect(subject.profile).to eq("~/.zshrc")
end

Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/utils/shell.rb
Expand Up @@ -39,6 +39,7 @@ def export_value(key, value, shell = preferred)

# return the shell profile file based on user's preferred shell
def profile
return ENV.fetch("ZDOTDIR", "~") + "/.zshrc" if preferred.eql? "zsh"
SHELL_PROFILE_MAP.fetch(preferred, "~/.bash_profile")
end

Expand Down

0 comments on commit 960b8b6

Please sign in to comment.