Skip to content

Commit

Permalink
Allow for escaped shell variables in job params.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuckaby committed Jul 27, 2022
1 parent a4a39ac commit 8c500b9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/job.js
Expand Up @@ -509,12 +509,12 @@ module.exports = Class.create({
child_opts.uid = parseInt( child_opts.uid );
child_opts.gid = parseInt( child_opts.gid );

// add plugin params as env vars, expand $INLINE vars
// add plugin params as env vars, expand $INLINE vars (unless escaped)
if (job.params) {
for (var key in job.params) {
child_opts.env[key.toUpperCase()] =
(''+job.params[key]).replace(/\$(\w+)/g, function(m_all, m_g1) {
return (m_g1 in child_opts.env) ? child_opts.env[m_g1] : '';
(''+job.params[key]).replace(/(\\?)\$(\w+)/g, function(m_all, m_g1, m_g2) {
return m_g1 ? ('$' + m_g2) : ((m_g2 in child_opts.env) ? child_opts.env[m_g2] : '');
});
}
}
Expand Down

0 comments on commit 8c500b9

Please sign in to comment.