Permalink
Browse files

switch to a command array, trailing spaces are too error-prone

  • Loading branch information...
1 parent 86b0f9c commit 7c19dcfea0f1280de8a587fc1f5474de2cd41f62 @bleything bleything committed Dec 9, 2011
Showing with 7 additions and 6 deletions.
  1. +7 −6 providers/userdefaults.rb
View
@@ -37,22 +37,23 @@ def load_current_resource
action :write do
unless @userdefaults.is_set
- cmd = "#{'sudo' if new_resource.sudo} defaults write "
+ cmd = ["defaults write"]
+ cmd.unshift('sudo') if new_resource.sudo
if new_resource.global
- cmd << "NSGlobalDomain "
+ cmd << "NSGlobalDomain"
else
- cmd << new_resource.domain + ' '
+ cmd << new_resource.domain
end
- cmd << "'#{new_resource.key}' " if new_resource.key
+ cmd << "'#{new_resource.key}'" if new_resource.key
if new_resource.value.is_a?(TrueClass) or new_resource.value.is_a?(FalseClass)
type = new_resource.type || "bool"
end
- cmd << "-#{type} " if type
+ cmd << "-#{type}" if type
cmd << "'#{new_resource.value}'"
- execute cmd
+ execute cmd.join(' ')
end
end

0 comments on commit 7c19dcf

Please sign in to comment.