summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-28 16:19:25 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-28 16:19:25 -0700
commit767ea4fc19cb29a55a81a55d1a13643ae3108f4c (patch)
tree811674aa726c2478352e2d87744ad5105db26da8
parent3b389790688adb1007b33476ec2e2b6111e26d76 (diff)
downloadmixlib-shellout-767ea4fc19cb29a55a81a55d1a13643ae3108f4c.tar.gz
remove LC_ALL default environment variable
now that we no longer support ruby 1.8.7 its time to retire this
-rw-r--r--lib/mixlib/shellout.rb19
-rw-r--r--lib/mixlib/shellout/windows.rb1
-rw-r--r--spec/mixlib/shellout_spec.rb21
3 files changed, 12 insertions, 29 deletions
diff --git a/lib/mixlib/shellout.rb b/lib/mixlib/shellout.rb
index 6261c21..a379ee8 100644
--- a/lib/mixlib/shellout.rb
+++ b/lib/mixlib/shellout.rb
@@ -27,7 +27,6 @@ module Mixlib
READ_WAIT_TIME = 0.01
READ_SIZE = 4096
DEFAULT_READ_TIMEOUT = 600
- DEFAULT_ENVIRONMENT = {'LC_ALL' => 'C'}
if RUBY_PLATFORM =~ /mswin|mingw32|windows/
require 'mixlib/shellout/windows'
@@ -84,7 +83,7 @@ module Mixlib
# Environment variables that will be set for the subcommand. Refer to the
# documentation of new to understand how ShellOut interprets this.
- attr_reader :environment
+ attr_accessor :environment
# The maximum time this command is allowed to run. Usually set via options
# to new
@@ -125,11 +124,7 @@ module Mixlib
# subprocess. This only has an effect if you call +error!+ after
# +run_command+.
# * +environment+: a Hash of environment variables to set before the command
- # is run. By default, the environment will *always* be set to 'LC_ALL' => 'C'
- # to prevent issues with multibyte characters in Ruby 1.8. To avoid this,
- # use :environment => nil for *no* extra environment settings, or
- # :environment => {'LC_ALL'=>nil, ...} to set other environment settings
- # without changing the locale.
+ # is run.
# * +timeout+: a Numeric value for the number of seconds to wait on the
# child process before raising an Exception. This is calculated as the
# total amount of time that ShellOut waited on the child process without
@@ -154,7 +149,7 @@ module Mixlib
@input = nil
@log_level = :debug
@log_tag = nil
- @environment = DEFAULT_ENVIRONMENT
+ @environment = {}
@cwd = nil
@valid_exit_codes = [0]
@terminate_reason = nil
@@ -315,13 +310,7 @@ 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)
+ self.environment = setting || {}
else
raise InvalidCommandOption, "option '#{option.inspect}' is not a valid option for #{self.class.name}"
diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb
index 2ae0256..137aaa9 100644
--- a/lib/mixlib/shellout/windows.rb
+++ b/lib/mixlib/shellout/windows.rb
@@ -200,7 +200,6 @@ module Mixlib
end
end
-
# cmd does not parse multiple quotes well unless the whole thing is wrapped up in quotes.
# https://github.com/opscode/mixlib-shellout/pull/2#issuecomment-4837859
# http://ss64.com/nt/syntax-esc.html
diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb
index e009dd8..0a1b0a8 100644
--- a/spec/mixlib/shellout_spec.rb
+++ b/spec/mixlib/shellout_spec.rb
@@ -42,8 +42,8 @@ describe Mixlib::ShellOut do
its(:live_stream) { should be_nil }
its(:input) { should be_nil }
- it "should set default environmental variables" do
- shell_cmd.environment.should == {"LC_ALL" => "C"}
+ it "should not set any default environmental variables" do
+ shell_cmd.environment.should == {}
end
end
@@ -314,7 +314,7 @@ describe Mixlib::ShellOut do
end
it "should add environment settings to the default" do
- shell_cmd.environment.should eql({'LC_ALL' => 'C', 'RUBY_OPTS' => '-w'})
+ shell_cmd.environment.should eql({'RUBY_OPTS' => '-w'})
end
context 'when setting custom environments' do
@@ -322,7 +322,7 @@ describe Mixlib::ShellOut do
let(:options) { { :env => environment } }
it "should also set the enviroment" do
- shell_cmd.environment.should eql({'LC_ALL' => 'C', 'RUBY_OPTS' => '-w'})
+ shell_cmd.environment.should eql({'RUBY_OPTS' => '-w'})
end
end
@@ -431,8 +431,8 @@ describe Mixlib::ShellOut do
context 'without specifying environment' do
let(:options) { nil }
- it "should use the C locale by default" do
- should eql('C')
+ it "should no longer use the C locale by default" do
+ should eql("")
end
end
@@ -459,8 +459,8 @@ describe Mixlib::ShellOut do
context 'when running under Unix', :unix_only do
let(:parent_locale) { ENV['LC_ALL'].to_s.strip }
- it "should use the parent process's locale" do
- should eql(parent_locale)
+ it "should unset the parent process's locale" do
+ should eql("")
end
end
@@ -574,7 +574,6 @@ describe Mixlib::ShellOut do
subject { chomped_stdout }
let(:cmd) { script_name }
-
context 'when running under Unix', :unix_only do
let(:script_content) { 'echo blah' }
@@ -620,7 +619,6 @@ describe Mixlib::ShellOut do
end
end
-
context 'with lots of long arguments' do
subject { chomped_stdout }
@@ -645,7 +643,6 @@ describe Mixlib::ShellOut do
end
end
-
context 'with backslashes' do
subject { stdout }
let(:backslashes) { %q{\\"\\\\} }
@@ -919,7 +916,6 @@ describe Mixlib::ShellOut do
end
end
-
context 'with open files for parent process' do
before do
@test_file = Tempfile.new('fd_test')
@@ -1056,7 +1052,6 @@ describe Mixlib::ShellOut do
CODE
end
-
it "should TERM the wayward child and grandchild, then KILL whoever is left" do
# note: let blocks don't correctly memoize if an exception is raised,
# so can't use executed_cmd