Permalink
Browse files

define env vars with double quotes, and escaping the values

  • Loading branch information...
1 parent 353e632 commit ff4a873b965f84605bfbd6c8f5b47d4f05871c2d @pedro pedro committed Nov 5, 2009
Showing with 6 additions and 2 deletions.
  1. +1 −1 lib/rush/box.rb
  2. +5 −1 spec/box_spec.rb
View
@@ -80,7 +80,7 @@ def command_with_environment(command, env) # :nodoc:
return command unless env
vars = env.map do |key, value|
- "export #{key}='#{value}'"
+ "export #{key}=\"#{value.gsub('"', '\\"')}\""
end
vars.push(command).join("\n")
end
View
@@ -38,7 +38,11 @@
end
it "builds a script of environment variables to prefix the bash command" do
- @box.command_with_environment('cmd', { :a => 'b' }).should == "export a='b'\ncmd"
+ @box.command_with_environment('cmd', { :a => 'b' }).should == "export a=\"b\"\ncmd"
+ end
+
+ it "escapes quotes on environment variables" do
+ @box.command_with_environment('cmd', { :a => 'a"b' }).should == "export a=\"a\\\"b\"\ncmd"
end
it "sets the environment variables from the provided hash" do

0 comments on commit ff4a873

Please sign in to comment.