@adamv  Thanks for your comment. I have improved this code.

https://github.com/tell-k/homebrew/commit/5ff5b1983799ceb4b2784d4a47762462d3fea0f6