Skip to content

Commit

Permalink
use Module#const_get instead of eval
Browse files Browse the repository at this point in the history
* may be a problem if the constant is scoped (like A::B), but this is not the case
  (const.split('::').inject(Object) { |c, part| c.const_get part } would solve that)
* this was noticed in a comment of 9afc85a but it has disappeared

Signed-off-by: Adam Vandenberg <flangy@gmail.com>
  • Loading branch information
eregon authored and adamv committed Mar 21, 2011
1 parent aa6d7fc commit eb121ee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Library/Homebrew/formula.rb
Expand Up @@ -378,7 +378,7 @@ def self.factory name

begin
klass_name = self.class_s(name)
klass = eval(klass_name)
klass = Object.const_get klass_name
rescue NameError
# TODO really this text should be encoded into the exception
# and only shown if the UI deems it correct to show it
Expand Down
3 changes: 1 addition & 2 deletions bin/brew
Expand Up @@ -71,10 +71,9 @@ begin

# Add example external commands to PATH before checking.
ENV['PATH'] += ":#{HOMEBREW_REPOSITORY}/Library/Contributions/examples"

if system "/usr/bin/which -s brew-#{cmd}"
%w[CACHE CELLAR LIBRARY_PATH PREFIX REPOSITORY].each do |e|
ENV["HOMEBREW_#{e}"] = eval "HOMEBREW_#{e}"
ENV["HOMEBREW_#{e}"] = Object.const_get "HOMEBREW_#{e}"
end
exec "brew-#{cmd}", *ARGV
elsif require? `/usr/bin/which brew-#{cmd}.rb`
Expand Down

0 comments on commit eb121ee

Please sign in to comment.