Check for the number of arguments given.

This commit is contained in:
Krzysztof Wilczynski 2011-03-12 23:05:56 +00:00
parent 49d208a13e
commit 0eea8ac101

View file

@ -40,11 +40,19 @@
#
module Puppet::Parser::Functions
newfunction(:load_vars, :type => :statement) do |args|
newfunction(:load_vars, :type => :statement) do |arguments|
number_of_arguments = arguments.size
if number_of_arguments < 2
raise(Puppet::ParseError, "Wrong number of arguments " +
"given (#{number_of_arguments} for 2)")
end
data = {}
file = args[0]
key = args[1] if args[1]
file = arguments[0]
key = arguments[1] if arguments[1]
if File.exists?(file)