Module: Chef::Mixin::ShellOut
- Included in:
- Application::Client, Application::Solo, Application::WindowsService, Cookbook::SyntaxCheck, DSL::Recipe, GuardInterpreter::DefaultGuardInterpreter, Knife::CookbookSCMRepo, Knife::CookbookSiteShare, Knife::Ssh, HomebrewUser, PowershellOut, Platform::Rebooter, Provider, Provider::Cron::Unix, Provider::Group, Provider::Ifconfig, Provider::Mount, Provider::Package, Provider::Package::Openbsd, Provider::Package::Rubygems::AlternateGemEnvironment, Provider::Package::Windows::Exe, Provider::Package::Windows::MSI, Provider::Package::Yum::YumCache, Provider::Service::Freebsd, Provider::Service::Openbsd, Provider::Service::Windows, Resource, Resource::Conditional, Resource::FreebsdPackage, Resource::OpenbsdPackage, Util::Selinux
- Defined in:
- lib/chef/mixin/shell_out.rb
Constant Summary collapse
- DEPRECATED_OPTIONS =
[ [:command_log_level, :log_level], [:command_log_prepend, :log_tag] ]
Instance Method Summary collapse
-
#run_command_compatible_options(command_args) ⇒ Object
CHEF-3090: Deprecate command_log_level and command_log_prepend Patterned after github.com/opscode/chef/commit/e1509990b559984b43e428d4d801c394e970f432.
-
#shell_out(*command_args) ⇒ Object
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.
-
#shell_out!(*command_args) ⇒ Object
call shell_out (using en_US.UTF-8) and raise errors.
- #shell_out_with_systems_locale(*command_args) ⇒ Object
- #shell_out_with_systems_locale!(*command_args) ⇒ Object
Instance Method Details
#run_command_compatible_options(command_args) ⇒ Object
CHEF-3090: Deprecate command_log_level and command_log_prepend Patterned after github.com/opscode/chef/commit/e1509990b559984b43e428d4d801c394e970f432
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/chef/mixin/shell_out.rb', line 76 def (command_args) return command_args unless command_args.last.is_a?(Hash) my_command_args = command_args.dup = my_command_args.last DEPRECATED_OPTIONS.each do |old_option, new_option| # Edge case: someone specifies :command_log_level and 'command_log_level' in the option hash next unless value = .delete(old_option) || .delete(old_option.to_s) deprecate_option old_option, new_option [new_option] = value end return my_command_args end |
#shell_out(*command_args) ⇒ Object
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.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/chef/mixin/shell_out.rb', line 31 def shell_out(*command_args) args = command_args.dup if args.last.is_a?(Hash) = args.pop.dup env_key = .has_key?(:env) ? :env : :environment [env_key] ||= {} [env_key] = [env_key].dup [env_key]["LC_ALL"] ||= Chef::Config[:internal_locale] unless [env_key].has_key?("LC_ALL") [env_key]["LANGUAGE"] ||= Chef::Config[:internal_locale] unless [env_key].has_key?("LANGUAGE") [env_key]["LANG"] ||= Chef::Config[:internal_locale] unless [env_key].has_key?("LANG") args << else args << { :environment => { "LC_ALL" => Chef::Config[:internal_locale], "LANGUAGE" => Chef::Config[:internal_locale], "LANG" => Chef::Config[:internal_locale], } } end shell_out_command(*args) end |
#shell_out!(*command_args) ⇒ Object
call shell_out (using en_US.UTF-8) and raise errors
54 55 56 57 58 |
# File 'lib/chef/mixin/shell_out.rb', line 54 def shell_out!(*command_args) cmd = shell_out(*command_args) cmd.error! cmd end |
#shell_out_with_systems_locale(*command_args) ⇒ Object
60 61 62 |
# File 'lib/chef/mixin/shell_out.rb', line 60 def shell_out_with_systems_locale(*command_args) shell_out_command(*command_args) end |
#shell_out_with_systems_locale!(*command_args) ⇒ Object
64 65 66 67 68 |
# File 'lib/chef/mixin/shell_out.rb', line 64 def shell_out_with_systems_locale!(*command_args) cmd = shell_out_with_systems_locale(*command_args) cmd.error! cmd end |