diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2011-01-16 14:27:24 -0800 |
|---|---|---|
| committer | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2011-01-16 14:28:13 -0800 |
| commit | c1b5c7f515a0add663fb532859d91e28ef37a971 (patch) | |
| tree | 0583622c86b3242ad8a1cc2d5c70d31030cc781c /lib | |
| parent | 76d1c2aefb32cc3688e3f7c0a5c8bbf713a123ed (diff) | |
| download | puppet-c1b5c7f515a0add663fb532859d91e28ef37a971.tar.gz puppet-c1b5c7f515a0add663fb532859d91e28ef37a971.tar.xz puppet-c1b5c7f515a0add663fb532859d91e28ef37a971.zip | |
(#5913) Fix Puppet::Application.find constant lookup behavior
Puppet::Application.find now only looks in the Puppet::Application
namespace for the given constant.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/application.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/puppet/application.rb b/lib/puppet/application.rb index f0159a65d..17ad69cee 100644 --- a/lib/puppet/application.rb +++ b/lib/puppet/application.rb @@ -212,10 +212,17 @@ class Application end def find(name) - self.const_get(name.to_s.capitalize) - rescue + klass = name.to_s.capitalize + + # const_defined? is used before const_get since const_defined? will only + # check within our namespace, whereas const_get will check ancestor + # trees as well, resulting in unexpected behaviour. + if !self.const_defined?(klass) puts "Unable to find application '#{name.to_s}'." Kernel::exit(1) + end + + self.const_get(klass) end def [](name) |
