summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-04-25 14:27:37 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-04-25 14:27:37 -0700
commitc22752ad04a77111db7301b23e995408a82775eb (patch)
treedf8dc9564fc627e38ec1971a3c7ae2dcd7dcc95b
parentf3075cd62af9a26e7d85987504610c6ad3af69b8 (diff)
downloadchef-c22752ad04a77111db7301b23e995408a82775eb.tar.gz
tighter code from @coderanger
-rw-r--r--lib/chef/mixin/shell_out.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb
index ff837a0eb5..be3446d67e 100644
--- a/lib/chef/mixin/shell_out.rb
+++ b/lib/chef/mixin/shell_out.rb
@@ -30,18 +30,13 @@ class Chef
# generally must support UTF-8 unicode.
def shell_out(*args, **options)
args = args.dup
- options ||= { :environment => {
- "LC_ALL" => Chef::Config[:internal_locale],
- "LANGUAGE" => Chef::Config[:internal_locale],
- "LANG" => Chef::Config[:internal_locale],
- } }
options = options.dup
env_key = options.has_key?(:env) ? :env : :environment
- options[env_key] ||= {}
- options[env_key] = options[env_key].dup
- options[env_key]["LC_ALL"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LC_ALL")
- options[env_key]["LANGUAGE"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LANGUAGE")
- options[env_key]["LANG"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LANG")
+ options[env_key] = {
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ }.update(options[env_key] || {})
shell_out_command(*args, **options)
end