From 7627f74e453278e47a62eaea941feeee58f8234b Mon Sep 17 00:00:00 2001 From: Ivan Yurchanka Date: Wed, 8 Jan 2025 17:13:10 +0100 Subject: [PATCH] Handle parentheses in variables in commands --- lib/kamal/secrets/dotenv/inline_command_substitution.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kamal/secrets/dotenv/inline_command_substitution.rb b/lib/kamal/secrets/dotenv/inline_command_substitution.rb index c9ef98799..16498ffbd 100644 --- a/lib/kamal/secrets/dotenv/inline_command_substitution.rb +++ b/lib/kamal/secrets/dotenv/inline_command_substitution.rb @@ -4,7 +4,7 @@ def install! ::Dotenv::Parser.substitutions.map! { |sub| sub == ::Dotenv::Substitutions::Command ? self : sub } end - def call(value, _env, overwrite: false) + def call(value, env, overwrite: false) # Process interpolated shell commands value.gsub(Dotenv::Substitutions::Command.singleton_class::INTERPOLATED_SHELL_COMMAND) do |*| # Eliminate opening and closing parentheses @@ -14,6 +14,7 @@ def call(value, _env, overwrite: false) # Command is escaped, don't replace it. $LAST_MATCH_INFO[0][1..] else + command = ::Dotenv::Substitutions::Variable.call(command, env) if command =~ /\A\s*kamal\s*secrets\s+/ # Inline the command inline_secrets_command(command)