diff options
-rw-r--r-- | CHANGELOG.md | 16 | ||||
-rw-r--r-- | lib/mixlib/shellout.rb | 19 | ||||
-rw-r--r-- | lib/mixlib/shellout/version.rb | 2 | ||||
-rw-r--r-- | lib/mixlib/shellout/windows.rb | 1 | ||||
-rw-r--r-- | mixlib-shellout.gemspec | 1 | ||||
-rw-r--r-- | spec/mixlib/shellout_spec.rb | 38 |
6 files changed, 27 insertions, 50 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 48c38bd..4dd0e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## Unreleased +* remove LC_ALL=C default setting, consumers should now set this if they + still need it. + +## Last Release: 1.6.0 + * [**Steven Proctor**:](https://github.com/stevenproctor) Updated link to posix-spawn in README.md. * [**Akshay Karle**:](https://github.com/akshaykarle) @@ -11,14 +16,3 @@ * [**Max Lincoln**](https://github.com/maxlinc): Support separate live stream for stderr. -## Last Release: 1.4.0 (08/04/2014) - -* [**Chris Armstrong**:](https://github.com/carmstrong) - Added error? to check if the command ran successfully. MIXLIB-18. - -* Improved process cleanup on timeouts. -* Enabled travis. -* Remove GC.disable hack for non-ruby 1.8.8 -* Handle ESRCH from getpgid of a zombie on OS X -* Fix "TypeError: no implicit conversion from nil to integer" due to nil "token" passed to CloseHandle. MIXLIB-25. -* $stderr of the command process is now reflected in the live_stream in addition to $stdout. (MIXLIB-19) 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/version.rb b/lib/mixlib/shellout/version.rb index 995af7e..7237753 100644 --- a/lib/mixlib/shellout/version.rb +++ b/lib/mixlib/shellout/version.rb @@ -1,5 +1,5 @@ module Mixlib class ShellOut - VERSION = "1.6.0.rc.0" + VERSION = "2.0.0.rc.0" end end 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/mixlib-shellout.gemspec b/mixlib-shellout.gemspec index f74f15f..582fc35 100644 --- a/mixlib-shellout.gemspec +++ b/mixlib-shellout.gemspec @@ -12,6 +12,7 @@ Gem::Specification.new do |s| s.email = "info@opscode.com" s.homepage = "http://wiki.opscode.com/" + s.required_ruby_version = ">= 1.9.3" s.add_development_dependency "rspec", "~> 2.0" diff --git a/spec/mixlib/shellout_spec.rb b/spec/mixlib/shellout_spec.rb index e009dd8..f7625e1 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 @@ -425,14 +425,22 @@ describe Mixlib::ShellOut do end context 'when handling locale' do + 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 + subject { stripped_stdout } let(:cmd) { ECHO_LC_ALL } let(:options) { { :environment => { 'LC_ALL' => locale } } } 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("en_US.UTF-8") end end @@ -447,20 +455,11 @@ 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 } - 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 +573,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 +618,6 @@ describe Mixlib::ShellOut do end end - context 'with lots of long arguments' do subject { chomped_stdout } @@ -645,7 +642,6 @@ describe Mixlib::ShellOut do end end - context 'with backslashes' do subject { stdout } let(:backslashes) { %q{\\"\\\\} } @@ -919,7 +915,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 +1051,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 |