summaryrefslogtreecommitdiff
path: root/lib/chef/mixin/shell_out.rb
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-06-25 14:13:54 -0700
committerClaire McQuin <claire@getchef.com>2014-06-27 12:43:55 -0700
commit8fbd370f59a1a4e89c976ce227b0809aca80e660 (patch)
tree06d2a5f508bf4d48dd5935a781947fb78f62420c /lib/chef/mixin/shell_out.rb
parentc94c7f4a3240531a15d85b9fca732adff5e47838 (diff)
downloadchef-8fbd370f59a1a4e89c976ce227b0809aca80e660.tar.gz
Properly modify environment option based on ENV
Diffstat (limited to 'lib/chef/mixin/shell_out.rb')
-rw-r--r--lib/chef/mixin/shell_out.rb30
1 files changed, 24 insertions, 6 deletions
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb
index 3f8b37a199..cbdfffeeb2 100644
--- a/lib/chef/mixin/shell_out.rb
+++ b/lib/chef/mixin/shell_out.rb
@@ -45,13 +45,31 @@ class Chef
end
def shell_out_with_systems_locale(*command_args)
- if command_args.last.is_a?(Hash)
- command_args.last[:environment] ||= {}
- command_args.last[:environment]['LC_ALL'] ||= ENV['LC_ALL']
- shell_out(*command_args)
- else
- shell_out(*command_args, :environment => {'LC_ALL' => ENV['LC_ALL']})
+ args = command_args.dup
+ unless ENV['LC_ALL'].nil?
+ if args.last.is_a?(Hash)
+ options = args.last
+ # Get the environment option and set environment['LC_ALL'] if not
+ # present.
+ if options.has_key?(:environment)
+ options_env = options[:environment]
+ elsif options.has_key?(:env)
+ options_env = options[:env]
+ else
+ options[:environment] = {}
+ options_env = options[:environment]
+ end
+
+ unless options_env.nil? || options_env.has_key?('LC_ALL')
+ options_env['LC_ALL'] = ENV['LC_ALL']
+ end
+ else
+ # Add the environment option
+ args << { :environment => { 'LC_ALL' => ENV['LC_ALL'] } }
+ end
end
+
+ shell_out(*args)
end
DEPRECATED_OPTIONS =