1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Add :env option to 'run' (and friends) so that you can specify environment variables to be injected into the new process' environment (closes #7223)

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6106 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2007-02-04 02:03:56 +00:00
parent d88197020a
commit c3c4ae0c5c
2 changed files with 22 additions and 1 deletions

View file

@ -1,3 +1,8 @@
*SVN*
* Add :env option to 'run' (and friends) so that you can specify environment variables to be injected into the new process' environment [Mathieu Lajugie]
*1.4.0* (February 3, 2007)
* Use the auth info for subversion more consistently [Jamis Buck]
@ -24,10 +29,12 @@
* Fix off-by-one bug in show_tasks width-computation [NeilW]
*1.3.1* (January 5, 2007)
* Fix connection problems when using gateways [Ezra Zygmuntowicz]
*1.3.0* (December 23, 2006)
* Deprecate rake integration in favor of invoking `cap' directly [Jamis Buck]
@ -58,6 +65,7 @@
* Added :as option to sudo, so you can specify who the command is executed as [Mark Imbriaco]
*1.2.0* (September 14, 2006)
* Add experimental 'shell' task [Jamis Buck]

View file

@ -9,7 +9,7 @@ module Capistrano
def initialize(servers, command, callback, options, actor) #:nodoc:
@servers = servers
@command = command.strip.gsub(/\r?\n/, "\\\n")
@command = extract_environment(options) + command.strip.gsub(/\r?\n/, "\\\n")
@callback = callback
@options = options
@actor = actor
@ -96,5 +96,18 @@ module Capistrano
end
end
end
# prepare a space-separated sequence of variables assignments
# intended to be prepended to a command, so the shell sets
# the environment before running the command.
# i.e.: options[:env] = {'PATH' => '/opt/ruby/bin:$PATH',
# 'TEST' => '( "quoted" )'}
# extract_environment(options) returns:
# "TEST=(\ \"quoted\"\ ) PATH=/opt/ruby/bin:$PATH"
def extract_environment(options)
Array(options[:env]).inject("") do |string, (name, value)|
string << %|#{name}=#{value.gsub(/"/, "\\\"").gsub(/ /, "\\ ")} |
end
end
end
end