summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-04-25 17:01:27 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-04-25 17:01:27 -0700
commitfa56afdc4b8c203d1eddd280528becfa43063881 (patch)
treec8822ec38a18fab3e4d9f0076decf6fe3da65de8
parentacf2d31ef5a564a8c543f8fcf96b95b4a546e2d8 (diff)
parent82ad81d4bc7b58db06e649136a3e200e12bffca0 (diff)
downloadchef-fa56afdc4b8c203d1eddd280528becfa43063881.tar.gz
Merge branch 'lcg/shell_out_syntax'
-rw-r--r--lib/chef/mixin/shell_out.rb31
-rw-r--r--spec/unit/mixin/shell_out_spec.rb4
2 files changed, 14 insertions, 21 deletions
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb
index d3598f64f5..1f7deb21d2 100644
--- a/lib/chef/mixin/shell_out.rb
+++ b/lib/chef/mixin/shell_out.rb
@@ -28,26 +28,15 @@ class Chef
# we use 'en_US.UTF-8' by default because we parse localized strings in English as an API and
# generally must support UTF-8 unicode.
- def shell_out(*command_args)
- args = command_args.dup
- if args.last.is_a?(Hash)
- options = args.pop.dup
- env_key = options.has_key?(:env) ? :env : :environment
- options[env_key] ||= {}
- options[env_key] = options[env_key].dup
- options[env_key]["LC_ALL"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LC_ALL")
- options[env_key]["LANGUAGE"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LANGUAGE")
- options[env_key]["LANG"] ||= Chef::Config[:internal_locale] unless options[env_key].has_key?("LANG")
- args << options
- else
- args << { :environment => {
- "LC_ALL" => Chef::Config[:internal_locale],
- "LANGUAGE" => Chef::Config[:internal_locale],
- "LANG" => Chef::Config[:internal_locale],
- } }
- end
-
- shell_out_command(*args)
+ def shell_out(*args, **options)
+ options = options.dup
+ env_key = options.has_key?(:env) ? :env : :environment
+ options[env_key] = {
+ "LC_ALL" => Chef::Config[:internal_locale],
+ "LANGUAGE" => Chef::Config[:internal_locale],
+ "LANG" => Chef::Config[:internal_locale],
+ }.update(options[env_key] || {})
+ shell_out_command(*args, **options)
end
# call shell_out (using en_US.UTF-8) and raise errors
@@ -99,7 +88,7 @@ class Chef
end
def deprecate_option(old_option, new_option)
- Chef::Log.logger.warn "DEPRECATION: Chef::Mixin::ShellOut option :#{old_option} is deprecated. Use :#{new_option}"
+ Chef.log_deprecation "DEPRECATION: Chef::Mixin::ShellOut option :#{old_option} is deprecated. Use :#{new_option}"
end
def io_for_live_stream
diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb
index 2dedd7d364..191ea920c0 100644
--- a/spec/unit/mixin/shell_out_spec.rb
+++ b/spec/unit/mixin/shell_out_spec.rb
@@ -34,6 +34,10 @@ describe Chef::Mixin::ShellOut do
let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) }
let(:assume_deprecation_log_level) { allow(Chef::Log).to receive(:level).and_return(:warn) }
+ before do
+ Chef::Config[:treat_deprecation_warnings_as_errors] = false
+ end
+
context "without options" do
let(:command_args) { [ cmd ] }