Fix the 'export PATH' message in link for a keg-only formula

Commit 4cae6a724e6d684eb157dd6d7328755694f228b2 introduced the message,
but it printed the wrong path, e.g. for `brew link sqlite`:

```
If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/sqlite:$PATH"' >> ~/.zshrc/bin
```

where `/bin` is appended at the end, but should be inserted before
`:$PATH`: `echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.zshrc`.
This patch fixes that and updates a test to verify it.
This commit is contained in:
Eugene Nikolsky 2017-04-01 19:00:24 -07:00
parent 974b5e2fa2
commit edd9a9717c
2 changed files with 6 additions and 4 deletions

View File

@ -86,8 +86,8 @@ module Homebrew
opt = HOMEBREW_PREFIX/"opt/#{keg.name}"
puts "\nIf you need to have this software first in your PATH instead consider running:"
puts " #{Utils::Shell.prepend_path_in_shell_profile(opt)}/bin" if bin.directory?
puts " #{Utils::Shell.prepend_path_in_shell_profile(opt)}/sbin" if sbin.directory?
puts " #{Utils::Shell.prepend_path_in_shell_profile(opt/"bin")}" if bin.directory?
puts " #{Utils::Shell.prepend_path_in_shell_profile(opt/"sbin")}" if sbin.directory?
end
def keg_only?(rack)

View File

@ -48,9 +48,11 @@ describe "brew link", :integration_test do
expect { brew "install", "testball1" }.to be_a_success
end
expect { brew "link", "testball1" }
expect { brew "link", "testball1", "SHELL" => "/bin/zsh" }
.to output(/testball1 is keg-only/).to_stderr
.and output(/Note that doing so can interfere with building software\./).to_stdout
.and output(a_string_matching(/Note that doing so can interfere with building software\./)
.and(matching("If you need to have this software first in your PATH instead consider running:")
.and(including("echo 'export PATH=\"#{HOMEBREW_PREFIX}/opt/testball1/bin:$PATH\"' >> ~/.zshrc")))).to_stdout
.and be_a_success
end
end