diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-06-11 15:02:42 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-06-11 15:32:53 -0700 |
commit | 5825eea4b139b9af089c3075d042d5d3160583ec (patch) | |
tree | fd79641ded1857ee4166b6e9ba774a35ab47b06b /lib/chef/provider | |
parent | 3889eddfc9944b23caea412d05c08b9b156cb50f (diff) | |
download | chef-5825eea4b139b9af089c3075d042d5d3160583ec.tar.gz |
Use .match? not =~ when match values aren't necessary
Autocorrected from RuboCop Performance which is now smart enough to detect when you use the match and when you don't. Using match? does not create any objects so it's slightly faster and uses less memory.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/chef/provider')
23 files changed, 49 insertions, 49 deletions
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb index a5669b0a4a..8a978b7eca 100644 --- a/lib/chef/provider/cron.rb +++ b/lib/chef/provider/cron.rb @@ -259,8 +259,8 @@ class Chef return "" if new_resource.time_out.empty? str = " timeout" - str << " --preserve-status" if new_resource.time_out["preserve-status"].to_s.downcase == "true" - str << " --foreground" if new_resource.time_out["foreground"].to_s.downcase == "true" + str << " --preserve-status" if new_resource.time_out["preserve-status"].to_s.casecmp("true") == 0 + str << " --foreground" if new_resource.time_out["foreground"].to_s.casecmp("true") == 0 str << " --kill-after #{new_resource.time_out["kill-after"]}" if new_resource.time_out["kill-after"] str << " --signal #{new_resource.time_out["signal"]}" if new_resource.time_out["signal"] str << " #{new_resource.time_out["duration"]};" diff --git a/lib/chef/provider/group/dscl.rb b/lib/chef/provider/group/dscl.rb index b506197dca..824ebe0477 100644 --- a/lib/chef/provider/group/dscl.rb +++ b/lib/chef/provider/group/dscl.rb @@ -39,7 +39,7 @@ class Chef result = dscl(*args) return "" if ( args.first =~ /^delete/ ) && ( result[1].exitstatus != 0 ) raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") unless result[1].exitstatus == 0 - raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") if result[2] =~ /No such key: / + raise(Chef::Exceptions::Group, "dscl error: #{result.inspect}") if /No such key: /.match?(result[2]) result[2] end @@ -77,7 +77,7 @@ class Chef gid = nil; next_gid_guess = 200 groups_gids = safe_dscl("list", "/Groups", "gid") while next_gid_guess < search_limit + 200 - if groups_gids =~ Regexp.new("#{Regexp.escape(next_gid_guess.to_s)}\n") + if groups_gids&.match?(Regexp.new("#{Regexp.escape(next_gid_guess.to_s)}\n")) next_gid_guess += 1 else gid = next_gid_guess diff --git a/lib/chef/provider/group/windows.rb b/lib/chef/provider/group/windows.rb index 6dda6a7cc2..45914b16e3 100644 --- a/lib/chef/provider/group/windows.rb +++ b/lib/chef/provider/group/windows.rb @@ -17,7 +17,7 @@ # require_relative "../user" -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) require_relative "../../util/windows/net_group" end diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb index 79f5bb78fe..cfabe292f9 100644 --- a/lib/chef/provider/ifconfig.rb +++ b/lib/chef/provider/ifconfig.rb @@ -59,12 +59,12 @@ class Chef @net_tools_version = shell_out("ifconfig", "--version") @net_tools_version.stdout.each_line do |line| - if line =~ /^net-tools (\d+\.\d+)/ + if /^net-tools (\d+\.\d+)/.match?(line) @ifconfig_version = line.match(/^net-tools (\d+\.\d+)/)[1] end end @net_tools_version.stderr.each_line do |line| - if line =~ /^net-tools (\d+\.\d+)/ + if /^net-tools (\d+\.\d+)/.match?(line) @ifconfig_version = line.match(/^net-tools (\d+\.\d+)/)[1] end end @@ -88,11 +88,11 @@ class Chef @int_name = line[0..9].strip @interfaces[@int_name] = { "hwaddr" => (line =~ /(HWaddr)/ ? ($') : "nil").strip.chomp } else - @interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /inet addr:/ - @interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Bcast:/ - @interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Mask:/ - @interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /MTU:/ - @interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if line =~ /Metric:/ + @interfaces[@int_name]["inet_addr"] = (line =~ /inet addr:(\S+)/ ? Regexp.last_match(1) : "nil") if /inet addr:/.match?(line) + @interfaces[@int_name]["bcast"] = (line =~ /Bcast:(\S+)/ ? Regexp.last_match(1) : "nil") if /Bcast:/.match?(line) + @interfaces[@int_name]["mask"] = (line =~ /Mask:(\S+)/ ? Regexp.last_match(1) : "nil") if /Mask:/.match?(line) + @interfaces[@int_name]["mtu"] = (line =~ /MTU:(\S+)/ ? Regexp.last_match(1) : "nil") if /MTU:/.match?(line) + @interfaces[@int_name]["metric"] = (line =~ /Metric:(\S+)/ ? Regexp.last_match(1) : "nil") if /Metric:/.match?(line) end next unless @interfaces.key?(new_resource.device) diff --git a/lib/chef/provider/mount/aix.rb b/lib/chef/provider/mount/aix.rb index 7a80c6511d..2cb29f5858 100644 --- a/lib/chef/provider/mount/aix.rb +++ b/lib/chef/provider/mount/aix.rb @@ -197,7 +197,7 @@ class Chef ::File.open("/etc/filesystems", "r").each_line do |line| case line when %r{^/.+:\s*$} - if line =~ /#{Regexp.escape(@new_resource.mount_point)}+:/ + if /#{Regexp.escape(@new_resource.mount_point)}+:/.match?(line) found_device = true else found_device = false diff --git a/lib/chef/provider/mount/windows.rb b/lib/chef/provider/mount/windows.rb index aea924b07f..81e9ad6b1d 100644 --- a/lib/chef/provider/mount/windows.rb +++ b/lib/chef/provider/mount/windows.rb @@ -17,7 +17,7 @@ # require_relative "../mount" -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) require_relative "../../util/windows/net_use" require_relative "../../util/windows/volume" end @@ -30,7 +30,7 @@ class Chef provides :mount, os: "windows" def is_volume(name) - name =~ /^\\\\\?\\Volume\{[\w-]+\}\\$/ ? true : false + /^\\\\\?\\Volume\{[\w-]+\}\\$/.match?(name) ? true : false end def initialize(new_resource, run_context) diff --git a/lib/chef/provider/noop.rb b/lib/chef/provider/noop.rb index fec948af54..74e24f6a44 100644 --- a/lib/chef/provider/noop.rb +++ b/lib/chef/provider/noop.rb @@ -26,7 +26,7 @@ class Chef end def method_missing(method_sym, *arguments, &block) - if method_sym.to_s =~ /^action_/ + if /^action_/.match?(method_sym.to_s) logger.trace("NoOp-ing for #{method_sym}") else super diff --git a/lib/chef/provider/package/openbsd.rb b/lib/chef/provider/package/openbsd.rb index 38ff84f105..6e32a424e2 100644 --- a/lib/chef/provider/package/openbsd.rb +++ b/lib/chef/provider/package/openbsd.rb @@ -57,7 +57,7 @@ class Chef end requirements.assert(:all_actions) do |a| a.assertion do - if new_resource.package_name =~ /^(.+?)--(.+)/ + if /^(.+?)--(.+)/.match?(new_resource.package_name) !new_resource.version else true diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb index 002c1f96d4..3182686c0e 100644 --- a/lib/chef/provider/package/portage.rb +++ b/lib/chef/provider/package/portage.rb @@ -71,7 +71,7 @@ class Chef if pkginfo.exitstatus != 0 pkginfo.stderr.each_line do |line| # cspell:disable-next-line - if line =~ /[Uu]nqualified atom .*match.* multiple/ + if /[Uu]nqualified atom .*match.* multiple/.match?(line) raise_error_for_query("matched multiple packages (please specify a category):\n#{pkginfo.inspect}") end end @@ -88,7 +88,7 @@ class Chef end pkginfo.stdout.chomp! - if pkginfo.stdout =~ /-r\d+$/ + if /-r\d+$/.match?(pkginfo.stdout) # Latest/Best version of the package is a revision (-rX). @candidate_version = pkginfo.stdout.split(/(?<=-)/).last(2).join else diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb index 51cb387cad..54e31bbd1e 100644 --- a/lib/chef/provider/package/powershell.rb +++ b/lib/chef/provider/package/powershell.rb @@ -59,7 +59,7 @@ class Chef names.each_with_index do |name, index| cmd = powershell_out(build_powershell_package_command("Install-Package '#{name}'", versions[index]), timeout: new_resource.timeout) next if cmd.nil? - raise Chef::Exceptions::PowershellCmdletException, "Failed to install package due to catalog signing error, use skip_publisher_check to force install" if cmd.stderr =~ /SkipPublisherCheck/ + raise Chef::Exceptions::PowershellCmdletException, "Failed to install package due to catalog signing error, use skip_publisher_check to force install" if /SkipPublisherCheck/.match?(cmd.stderr) end end diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb index fa2b5a66d7..be4f1a149c 100644 --- a/lib/chef/provider/package/rubygems.rb +++ b/lib/chef/provider/package/rubygems.rb @@ -420,7 +420,7 @@ class Chef end def is_omnibus? - if RbConfig::CONFIG["bindir"] =~ %r{/(opscode|chef|chefdk)/embedded/bin} + if %r{/(opscode|chef|chefdk)/embedded/bin}.match?(RbConfig::CONFIG["bindir"]) logger.trace("#{new_resource} detected omnibus installation in #{RbConfig::CONFIG["bindir"]}") # Omnibus installs to a static path because of linking on unix, find it. true @@ -447,7 +447,7 @@ class Chef scheme = URI.parse(new_resource.source).scheme # URI.parse gets confused by MS Windows paths with forward slashes. - scheme = nil if scheme =~ /^[a-z]$/ + scheme = nil if /^[a-z]$/.match?(scheme) %w{http https}.include?(scheme) rescue URI::InvalidURIError logger.trace("#{new_resource} failed to parse source '#{new_resource.source}' as a URI, assuming a local path") diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb index 0624224f57..1ce8add80d 100644 --- a/lib/chef/provider/package/windows/msi.rb +++ b/lib/chef/provider/package/windows/msi.rb @@ -18,7 +18,7 @@ # TODO: Allow new_resource.source to be a Product Code as a GUID for uninstall / network install -require_relative "../../../win32/api/installer" if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +require_relative "../../../win32/api/installer" if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) require_relative "../../../mixin/shell_out" class Chef @@ -26,7 +26,7 @@ class Chef class Package class Windows class MSI - include Chef::ReservedNames::Win32::API::Installer if RUBY_PLATFORM =~ /mswin|mingw32|windows/ + include Chef::ReservedNames::Win32::API::Installer if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) include Chef::Mixin::ShellOut def initialize(resource, uninstall_entries) @@ -84,7 +84,7 @@ class Chef .map(&:uninstall_string).uniq.each do |uninstall_string| uninstall_string = "msiexec /x #{uninstall_string.match(/{.*}/)}" uninstall_string += expand_options(new_resource.options) - uninstall_string += " /q" unless uninstall_string.downcase =~ %r{ /q} + uninstall_string += " /q" unless %r{ /q}.match?(uninstall_string.downcase) logger.trace("#{new_resource} removing MSI package version using '#{uninstall_string}'") shell_out!(uninstall_string, default_env: false, timeout: new_resource.timeout, returns: new_resource.returns) end diff --git a/lib/chef/provider/package/windows/registry_uninstall_entry.rb b/lib/chef/provider/package/windows/registry_uninstall_entry.rb index 22bc00a9f7..548b911ecb 100644 --- a/lib/chef/provider/package/windows/registry_uninstall_entry.rb +++ b/lib/chef/provider/package/windows/registry_uninstall_entry.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require "win32/registry" if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +require "win32/registry" if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) class Chef class Provider diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb index 26332c061f..ef2461848d 100644 --- a/lib/chef/provider/remote_file/http.rb +++ b/lib/chef/provider/remote_file/http.rb @@ -130,7 +130,7 @@ class Chef # which tricks Chef::REST into decompressing the response body. In this # case you'd end up with a tar archive (no gzip) named, e.g., foo.tgz, # which is not what you wanted. - if uri.to_s =~ /gz$/ + if /gz$/.match?(uri.to_s) logger.trace("Turning gzip compression off due to filename ending in gz") opts[:disable_gzip] = true end diff --git a/lib/chef/provider/service/arch.rb b/lib/chef/provider/service/arch.rb index 24064f26ac..fe09baf2d5 100644 --- a/lib/chef/provider/service/arch.rb +++ b/lib/chef/provider/service/arch.rb @@ -33,7 +33,7 @@ class Chef::Provider::Service::Arch < Chef::Provider::Service::Init def load_current_resource raise Chef::Exceptions::Service, "Could not find /etc/rc.conf" unless ::File.exists?("/etc/rc.conf") - raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless ::File.read("/etc/rc.conf") =~ /DAEMONS=\((.*)\)/m + raise Chef::Exceptions::Service, "No DAEMONS found in /etc/rc.conf" unless /DAEMONS=\((.*)\)/m.match?(::File.read("/etc/rc.conf")) super diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb index 259652a2d9..a89907bb50 100644 --- a/lib/chef/provider/service/debian.rb +++ b/lib/chef/provider/service/debian.rb @@ -76,9 +76,9 @@ class Chef in_info = false ::File.readlines(path).each_with_object([]) do |line, acc| - if line =~ /^### BEGIN INIT INFO/ + if /^### BEGIN INIT INFO/.match?(line) in_info = true - elsif line =~ /^### END INIT INFO/ + elsif /^### END INIT INFO/.match?(line) break acc elsif in_info if line =~ /Default-(Start|Stop):\s+(\d.*)/ diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb index c368815418..fe42e2133c 100644 --- a/lib/chef/provider/service/openbsd.rb +++ b/lib/chef/provider/service/openbsd.rb @@ -91,7 +91,7 @@ class Chef old_services_list = rc_conf_local.match(/^pkg_scripts="(.*)"/) old_services_list = old_services_list ? old_services_list[1].split(" ") : [] new_services_list = old_services_list + [new_resource.service_name] - if rc_conf_local =~ /^pkg_scripts="(.*)"/ + if /^pkg_scripts="(.*)"/.match?(rc_conf_local) new_rcl = rc_conf_local.sub(/^pkg_scripts="(.*)"/, "pkg_scripts=\"#{new_services_list.join(" ")}\"") else new_rcl = rc_conf_local + "\n" + "pkg_scripts=\"#{new_services_list.join(" ")}\"\n" @@ -158,7 +158,7 @@ class Chef result = false var_name = builtin_service_enable_variable_name if var_name - if rc_conf =~ /^#{Regexp.escape(var_name)}=(.*)/ + if /^#{Regexp.escape(var_name)}=(.*)/.match?(rc_conf) result = true end end @@ -170,7 +170,7 @@ class Chef var_name = builtin_service_enable_variable_name if var_name if m = rc_conf.match(/^#{Regexp.escape(var_name)}=(.*)/) - unless m[1] =~ /"?[Nn][Oo]"?/ + unless /"?[Nn][Oo]"?/.match?(m[1]) result = true end end @@ -186,7 +186,7 @@ class Chef if var_name if m = rc_conf_local.match(/^#{Regexp.escape(var_name)}=(.*)/) @enabled_state_found = true - unless m[1] =~ /"?[Nn][Oo]"?/ # e.g. looking for httpd_flags=NO + unless /"?[Nn][Oo]"?/.match?(m[1]) # e.g. looking for httpd_flags=NO result = true end end diff --git a/lib/chef/provider/service/redhat.rb b/lib/chef/provider/service/redhat.rb index 6851e7f150..ec78ef2240 100644 --- a/lib/chef/provider/service/redhat.rb +++ b/lib/chef/provider/service/redhat.rb @@ -87,7 +87,7 @@ class Chef chkconfig.stdout.split(/\s+/)[1..-1].each do |level| index = level.split(":").first status = level.split(":").last - if level =~ CHKCONFIG_ON + if CHKCONFIG_ON.match?(level) @current_run_levels << index.to_i all_levels_match = false unless run_levels.include?(index.to_i) else diff --git a/lib/chef/provider/service/windows.rb b/lib/chef/provider/service/windows.rb index 6c1f7c3583..88bb282be9 100644 --- a/lib/chef/provider/service/windows.rb +++ b/lib/chef/provider/service/windows.rb @@ -20,7 +20,7 @@ require_relative "simple" require_relative "../../win32_service_constants" -if RUBY_PLATFORM =~ /mswin|mingw32|windows/ +if RUBY_PLATFORM.match?(/mswin|mingw32|windows/) require_relative "../../win32/error" require "win32/service" end diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb index 270f7457fa..18fc9d3a3c 100644 --- a/lib/chef/provider/subversion.rb +++ b/lib/chef/provider/subversion.rb @@ -122,7 +122,7 @@ class Chef # If the specified revision is an integer, trust it. def revision_int @revision_int ||= begin - if new_resource.revision =~ /^\d+$/ + if /^\d+$/.match?(new_resource.revision) new_resource.revision else command = scm(:info, new_resource.repository, new_resource.svn_info_args, authentication, "-r#{new_resource.revision}") @@ -211,7 +211,7 @@ class Chef def scm(*args) binary = svn_binary - binary = "\"#{binary}\"" if binary =~ /\s/ + binary = "\"#{binary}\"" if /\s/.match?(binary) [binary, *args].compact.join(" ") end diff --git a/lib/chef/provider/user/dscl.rb b/lib/chef/provider/user/dscl.rb index 50030c885f..fade7097b5 100644 --- a/lib/chef/provider/user/dscl.rb +++ b/lib/chef/provider/user/dscl.rb @@ -215,7 +215,7 @@ in 'password', with the associated 'salt' and 'iterations'.") next_uid_guess = base_uid users_uids = run_dscl("list", "/Users", "uid") while next_uid_guess < search_limit + base_uid - if users_uids =~ Regexp.new("#{Regexp.escape(next_uid_guess.to_s)}\n") + if users_uids&.match?(Regexp.new("#{Regexp.escape(next_uid_guess.to_s)}\n")) next_uid_guess += 1 else uid = next_uid_guess @@ -291,7 +291,7 @@ in 'password', with the associated 'salt' and 'iterations'.") end def validate_home_dir_specification! - unless new_resource.home =~ %r{^/} + unless %r{^/}.match?(new_resource.home) raise(Chef::Exceptions::InvalidHomeDirectory, "invalid path spec for User: '#{new_resource.username}', home directory: '#{new_resource.home}'") end end @@ -587,7 +587,7 @@ in 'password', with the associated 'salt' and 'iterations'.") result = shell_out("dscl", ".", "-#{args[0]}", args[1..-1]) return "" if ( args.first =~ /^delete/ ) && ( result.exitstatus != 0 ) raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") unless result.exitstatus == 0 - raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if result.stdout =~ /No such key: / + raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if /No such key: /.match?(result.stdout) result.stdout end diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb index bab8588151..40b5985cb1 100644 --- a/lib/chef/provider/user/linux.rb +++ b/lib/chef/provider/user/linux.rb @@ -96,7 +96,7 @@ class Chef passwd_s = shell_out("passwd", "-S", new_resource.username, returns: [ 0, 1 ]) # checking "does not exist" has to come before exit code handling since centos and ubuntu differ in exit codes - if passwd_s.stderr =~ /does not exist/ + if /does not exist/.match?(passwd_s.stderr) return false if whyrun_mode? raise Chef::Exceptions::User, "User #{new_resource.username} does not exist when checking lock status for #{new_resource}" @@ -108,8 +108,8 @@ class Chef # now the actual output parsing @locked = nil status_line = passwd_s.stdout.split(" ") - @locked = false if status_line[1] =~ /^[PN]/ - @locked = true if status_line[1] =~ /^L/ + @locked = false if /^[PN]/.match?(status_line[1]) + @locked = true if /^L/.match?(status_line[1]) raise Chef::Exceptions::User, "Cannot determine if user #{new_resource.username} is locked for #{new_resource}" if @locked.nil? diff --git a/lib/chef/provider/user/mac.rb b/lib/chef/provider/user/mac.rb index a2561e2ccd..34307aff1e 100644 --- a/lib/chef/provider/user/mac.rb +++ b/lib/chef/provider/user/mac.rb @@ -163,7 +163,7 @@ class Chef # a problem. We'll check stderr and make sure we see that it finished # correctly. res = run_sysadminctl(cmd) - unless res.downcase =~ /creating user/ + unless /creating user/.match?(res.downcase) raise Chef::Exceptions::User, "error when creating user: #{res}" end @@ -309,7 +309,7 @@ class Chef # sysadminctl doesn't exit with a non-zero exit code if it encounters # a problem. We'll check stderr and make sure we see that it finished res = run_sysadminctl(cmd) - unless res.downcase =~ /deleting record|not found/ + unless /deleting record|not found/.match?(res.downcase) raise Chef::Exceptions::User, "error deleting user: #{res}" end @@ -372,7 +372,7 @@ class Chef next_uid_guess = base_uid users_uids = run_dscl("list", "/Users", "uid") while next_uid_guess < search_limit + base_uid - if users_uids =~ Regexp.new("#{Regexp.escape(next_uid_guess.to_s)}\n") + if users_uids&.match?(Regexp.new("#{Regexp.escape(next_uid_guess.to_s)}\n")) next_uid_guess += 1 else uid = next_uid_guess @@ -430,7 +430,7 @@ class Chef # sysadminctl doesn't exit with a non-zero exit code if it encounters # a problem. We'll check stderr and make sure we see that it finished res = run_sysadminctl(cmd) - unless res.downcase =~ /done/ + unless /done/.match?(res.downcase) raise Chef::Exceptions::User, "error when modifying SecureToken: #{res}" end @@ -611,7 +611,7 @@ class Chef result = shell_out("dscl", "-plist", ".", "-#{args[0]}", args[1..-1]) return "" if ( args.first =~ /^delete/ ) && ( result.exitstatus != 0 ) raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") unless result.exitstatus == 0 - raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if result.stdout =~ /No such key: / + raise(Chef::Exceptions::DsclCommandFailed, "dscl error: #{result.inspect}") if /No such key: /.match?(result.stdout) result.stdout end |