summaryrefslogtreecommitdiff
path: root/lib/chef/mixin/shell_out.rb
diff options
context:
space:
mode:
authorClaire McQuin <claire@getchef.com>2014-06-26 11:27:18 -0700
committerClaire McQuin <claire@getchef.com>2014-06-27 12:43:55 -0700
commitba42749bf65ea7eb6a197b12fa298792a7923034 (patch)
tree99170b55a63dbbca12a0598cb99b23fad294862e /lib/chef/mixin/shell_out.rb
parent4c77658ef23c689a1364414f0c7d2bfca47c4dcd (diff)
downloadchef-ba42749bf65ea7eb6a197b12fa298792a7923034.tar.gz
Set environment option's 'LC_ALL' to nil if not present in option.
Diffstat (limited to 'lib/chef/mixin/shell_out.rb')
-rw-r--r--lib/chef/mixin/shell_out.rb35
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb
index cbdfffeeb2..4e462a17be 100644
--- a/lib/chef/mixin/shell_out.rb
+++ b/lib/chef/mixin/shell_out.rb
@@ -44,29 +44,26 @@ class Chef
cmd
end
+ # environment['LC_ALL'] should be nil or what the user specified
def shell_out_with_systems_locale(*command_args)
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
+ if args.last.is_a?(Hash)
+ options = args.last
+ if options.has_key?(:environment)
+ options_env = options[:environment]
+ elsif options.has_key?(:env)
+ options_env = options[:env]
else
- # Add the environment option
- args << { :environment => { 'LC_ALL' => ENV['LC_ALL'] } }
+ # No environment option provided, make one
+ options[:environment] = {}
+ options_env = options[:environment]
end
+
+ unless options_env.has_key?('LC_ALL')
+ options_env['LC_ALL'] = nil
+ end
+ else
+ args << { :environment => { 'LC_ALL' => nil } }
end
shell_out(*args)