implemetn array arguments from #1569

This commit is contained in:
Michal Papis 2013-07-19 03:35:37 +02:00
parent 14ae9ed039
commit fb96396f65
1 changed files with 10 additions and 2 deletions

View File

@ -5,8 +5,11 @@ module VagrantPlugins
module Shell module Shell
class Provisioner < Vagrant.plugin("2", :provisioner) class Provisioner < Vagrant.plugin("2", :provisioner)
def provision def provision
args = "" case config.args
args = " #{config.args}" if config.args when String then args = " #{config.args}"
when Array then args = " #{config.args.map{|arg| quote_and_escape(arg)}.join(" ")}"
else args = ""
end
command = "chmod +x #{config.upload_path} && #{config.upload_path}#{args}" command = "chmod +x #{config.upload_path} && #{config.upload_path}#{args}"
with_script_file do |path| with_script_file do |path|
@ -44,6 +47,11 @@ module VagrantPlugins
protected protected
# Quote and escape strings for shell execution, thanks to @capistrano
def quote_and_escape(text, quote = '"')
"#{quote}#{text.gsub(/#{quote}/) { |m| "#{m}\\#{m}#{m}" }}#{quote}"
end
# This method yields the path to a script to upload and execute # This method yields the path to a script to upload and execute
# on the remote server. This method will properly clean up the # on the remote server. This method will properly clean up the
# script file if needed. # script file if needed.