provisioners/shell: clean up fixnum handling

This commit is contained in:
Mitchell Hashimoto 2014-02-14 12:43:27 -08:00
parent 3041ce1a7a
commit 8c9fde41e9
2 changed files with 10 additions and 4 deletions

View File

@ -29,6 +29,10 @@ module VagrantPlugins
@privileged = true if @privileged == UNSET_VALUE
@binary = false if @binary == UNSET_VALUE
@keep_color = false if @keep_color == UNSET_VALUE
if @args && !@args.is_a?(Array) && args_valid?
@args = @args.to_s
end
end
def validate(machine)
@ -66,11 +70,13 @@ module VagrantPlugins
# string or as an array.
def args_valid?
return true if !args
return true if args.is_a?(String) or args.is_a?(Fixnum)
return true if args.is_a?(String)
return true if args.is_a?(Fixnum)
if args.is_a?(Array)
args.each do |a|
return false if not a.kind_of?(String) and not a.kind_of?(Fixnum)
return false if !a.kind_of?(String) && !a.kind_of?(Fixnum)
end
return true
end
end

View File

@ -8,10 +8,10 @@ module VagrantPlugins
class Provisioner < Vagrant.plugin("2", :provisioner)
def provision
args = ""
if config.args.is_a?(String) or config.args.is_a?(Fixnum)
if config.args.is_a?(String)
args = " #{config.args.to_s}"
elsif config.args.is_a?(Array)
args = config.args.map { |a| quote_and_escape(a.to_s) }
args = config.args.map { |a| quote_and_escape(a) }
args = " #{args.join(" ")}"
end