mathie/chef-homebrew — pull request #10 by bluepojo (2012-03-29 23:32:14+00:00)
Title: Fixed #current_installed_version when multiple versions of a package are...

If you have multiple versions (with one or more unlinked) of a package installed, #current_installed_version will return the first one in the list, which is not always correct.

josiah-kiehl:homebrew jkiehl$ brew list --versions | grep znc
znc 0.202 0.204

Using the current command:

josiah-kiehl:Library jkiehl$ git checkout HEAD /usr/local/Library/Formula/znc.rb
josiah-kiehl:Library jkiehl$ brew unlink znc
Unlinking /usr/local/Cellar/znc/0.202... 10 links removed
josiah-kiehl:Library jkiehl$ brew link znc
Linking /usr/local/Cellar/znc/0.204... 10 symlinks created
josiah-kiehl:Library jkiehl$ brew list --versions | awk '/^znc / {print $2}'
0.202

0.204 is the currently linked version, however the command returns 0.202.

Using the new command:

josiah-kiehl:Library$ brew info znc | awk '/\*$/ { print $1 }' | sed 's/.*\///'
0.204