implemetn array arguments from #1569
This commit is contained in:
parent
14ae9ed039
commit
fb96396f65
|
@ -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.
|
||||||
|
|
Loading…
Reference in New Issue