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.
This commit is contained in:
Consolatis 2023-09-13 15:25:05 +02:00
parent bd6efe4849
commit 8c343e89c7

View file

@ -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);