Skip to content
Browse files

fix bug with non-string env vars - convert to_s before escaping

  • Loading branch information...
1 parent 7afe6bb commit 1ae58dfa357c55211d1cb105045d0ebc23b66578 @pedro pedro committed Nov 10, 2009
Showing with 5 additions and 1 deletion.
  1. +1 −1 lib/rush/box.rb
  2. +4 −0 spec/box_spec.rb
View
2 lib/rush/box.rb
@@ -80,7 +80,7 @@ def command_with_environment(command, env) # :nodoc:
return command unless env
vars = env.map do |key, value|
- "export #{key}=\"#{value.gsub('"', '\\"')}\""
+ "export #{key}=\"#{value.to_s.gsub('"', '\\"')}\""
end
vars.push(command).join("\n")
end
View
4 spec/box_spec.rb
@@ -45,6 +45,10 @@
@box.command_with_environment('cmd', { :a => 'a"b' }).should == "export a=\"a\\\"b\"\ncmd"
end
+ it "converts environment variables to_s" do
+ @box.command_with_environment('cmd', { :a => nil, :b => 123 }).should == "export a=\"\"\nexport b=\"123\"\ncmd"
+ end
+
it "sets the environment variables from the provided hash" do
@box.connection.stub!(:bash)
@box.should_receive(:command_with_environment).with('cmd', { 1 => 2 })

0 comments on commit 1ae58df

Please sign in to comment.
Something went wrong with that request. Please try again.