From c5c08863892cd8d08dd5a3a6ee9f1fe918a9c8f3 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Fri, 13 Sep 2024 14:43:24 +0200 Subject: [PATCH] Simplify detection of %s in custom_command This uses the cheaper include? to determine if %s is in custom_command. It also simplifies the expression with a safe operator. --- lib/puppet_x/bodeco/archive.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_x/bodeco/archive.rb b/lib/puppet_x/bodeco/archive.rb index 79f2652..d163ca0 100644 --- a/lib/puppet_x/bodeco/archive.rb +++ b/lib/puppet_x/bodeco/archive.rb @@ -44,7 +44,7 @@ def extract(path = root_dir, opts = {}) custom_command = opts.fetch(:custom_command, nil) options = opts.fetch(:options) Dir.chdir(path) do - cmd = if custom_command && custom_command =~ %r{%s} + cmd = if custom_command&.include?('%s') custom_command % @file_path elsif custom_command "#{custom_command} #{options} #{@file_path}"