diff options
author | sersut <serdar@opscode.com> | 2013-06-14 15:28:50 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2013-06-14 15:28:50 -0700 |
commit | 596d523e718713b3d772f44e5dbbf122c1b84a18 (patch) | |
tree | 6ef165aced11136b713e2e9cc87d039ba87561f5 | |
parent | 29ea7170762c01fd0e107a81e5aecde9a298099b (diff) | |
download | mixlib-shellout-596d523e718713b3d772f44e5dbbf122c1b84a18.tar.gz |
Make sure the parent process' LC_ALL setting is passed to subprocess when LC_ALL is set to nil in the :environment setting.
-rw-r--r-- | lib/mixlib/shellout.rb | 6 | ||||
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb index 63744f1..a267162 100644 --- a/lib/mixlib/shellout.rb +++ b/lib/mixlib/shellout.rb @@ -290,8 +290,14 @@ module Mixlib when 'log_tag' self.log_tag = setting when 'environment', 'env' + # Set the LC_ALL from the parent process if the user wanted + # to use the default. + if setting && setting.has_key?("LC_ALL") && setting['LC_ALL'].nil? + setting['LC_ALL'] = ENV['LC_ALL'] + end # passing :environment => nil means don't set any new ENV vars @environment = setting.nil? ? {} : @environment.dup.merge!(setting) + else raise InvalidCommandOption, "option '#{option.inspect}' is not a valid option for #{self.class.name}" end diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index 131c5e1..bc043bc 100644 --- a/spec/mixlib/shellout_spec.rb +++ b/spec/mixlib/shellout_spec.rb @@ -383,6 +383,15 @@ describe Mixlib::ShellOut do context 'with LC_ALL set to nil' do let(:locale) { nil } + before do + @original_lc_all = ENV['LC_ALL'] + ENV['LC_ALL'] = "en_US.UTF-8" + end + + after do + ENV['LC_ALL'] = @original_lc_all + end + context 'when running under Unix', :unix_only do let(:parent_locale) { ENV['LC_ALL'].to_s.strip } |