summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/functions/generate.rb
diff options
context:
space:
mode:
authorPaul Lathrop <plathrop@digg.com>2010-04-06 18:19:34 -0700
committerJames Turnbull <james@lovedthanlost.net>2010-04-13 17:28:16 +1000
commit9bc2f281a18abde64061b152631f3a867128cdc5 (patch)
treef4b6d7541866e00e3903151523421ab13fdd26f0 /lib/puppet/parser/functions/generate.rb
parent3ee6834a81b1a997a426fe086e1d98d03f8d8b2d (diff)
downloadpuppet-9bc2f281a18abde64061b152631f3a867128cdc5.tar.gz
puppet-9bc2f281a18abde64061b152631f3a867128cdc5.tar.xz
puppet-9bc2f281a18abde64061b152631f3a867128cdc5.zip
Fixes #3295 - generate() now sets the working directory to the directory containing the specified command.
Also adds rspec tests for generate().
Diffstat (limited to 'lib/puppet/parser/functions/generate.rb')
-rw-r--r--lib/puppet/parser/functions/generate.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/puppet/parser/functions/generate.rb b/lib/puppet/parser/functions/generate.rb
index 18fe883b4..55161df1a 100644
--- a/lib/puppet/parser/functions/generate.rb
+++ b/lib/puppet/parser/functions/generate.rb
@@ -1,6 +1,6 @@
# Runs an external command and returns the results
Puppet::Parser::Functions::newfunction(:generate, :type => :rvalue,
- :doc => "Calls an external command on the Puppet master and returns
+ :doc => "Calls an external command on the Puppet master and returns
the results of the command. Any arguments are passed to the external command as
arguments. If the generator does not exit with return code of 0,
the generator is considered to have failed and a parse error is
@@ -26,7 +26,9 @@ Puppet::Parser::Functions::newfunction(:generate, :type => :rvalue,
end
begin
- output = Puppet::Util.execute(args)
+ Dir.chdir(File.dirname(args[0])) do
+ output = Puppet::Util.execute(args)
+ end
rescue Puppet::ExecutionFailure => detail
raise Puppet::ParseError, "Failed to execute generator %s: %s" %
[args[0], detail]