diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-04-25 10:16:22 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-04-25 10:16:22 -0700 |
commit | f3075cd62af9a26e7d85987504610c6ad3af69b8 (patch) | |
tree | 3920497c89755bc65d01b4693ca3d9cfca65005e /lib/chef/mixin | |
parent | bfd2dacc0b8c51f82d2a9fad8b9b1dde4a748a38 (diff) | |
download | chef-f3075cd62af9a26e7d85987504610c6ad3af69b8.tar.gz |
modernize shell_out method syntax
**options has worked ever since we've deprecated ruby 1.9.x
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r-- | lib/chef/mixin/shell_out.rb | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/lib/chef/mixin/shell_out.rb b/lib/chef/mixin/shell_out.rb index d3598f64f5..ff837a0eb5 100644 --- a/lib/chef/mixin/shell_out.rb +++ b/lib/chef/mixin/shell_out.rb @@ -28,26 +28,21 @@ 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 => { + def shell_out(*args, **options) + args = args.dup + options ||= { :environment => { "LC_ALL" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], } } - end - - shell_out_command(*args) + options = options.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") + shell_out_command(*args, **options) end # call shell_out (using en_US.UTF-8) and raise errors |