From 8c343e89c792d0e55f1137d44a5ac08eab6b1084 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Wed, 13 Sep 2023 15:25:05 +0200 Subject: [PATCH] actions: Prevent env var expansion for subshells like `$()` We currently expand Execute action commands like `sh -c 'echo $(date) >> /tmp/foo'` to `sh -c 'echo (date) >> /tmp/foo'` This obviously breaks the subshell. This patch fixes it by preventing single `$` being replaced with nothing. --- src/common/buf.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/common/buf.c b/src/common/buf.c index 740489dd..45adf72e 100644 --- a/src/common/buf.c +++ b/src/common/buf.c @@ -33,6 +33,13 @@ buf_expand_shell_variables(struct buf *s) ++p; } *p = '\0'; + + /* Don't expand single $ (as used by subshells) */ + if (!strlen(environment_variable.buf)) { + buf_add(&new, "$"); + continue; + } + i += strlen(environment_variable.buf); strip_curly_braces(environment_variable.buf); p = getenv(environment_variable.buf);