Handle parentheses in variables in commands
Variables with parentheses are not handled correctly in commands:
FOO='passwo(rd'
BAR=$(echo '$FOO')
Result:
expected: {"BAR"=>"passwo(rd", "FOO"=>"passwo(rd"}
got: {"BAR"=>"$(echo 'passwo(rd')", "FOO"=>"passwo(rd"}
The solution I suggest is to parse commands first and expand variables before executing commands.
Dependencies
This change will break kamal which is included in Rails by default. This is how I want to handle it:
- Get an approval for the
dotenvpatch but not merge it. - Deliver backward compatible fix to
kamalhttps://github.com/basecamp/kamal/pull/1346 - Merge this PR once the patched version of
kamalis released.
Will this also fix #530 (improperly expanding double-quotes in command variables)? This makes Kamal only able to use JSON secrets when its double-quotes are backslashed. I see you escaped quotes and braces in your secrets example. Shouldn't neither be necessary, so the secrets can be normal JSON?
@mrj Unfortunately this PR does not fix the issue you reported.
@i7an thanks for reporting this and coming up with a fix. I'm good with going forward with this, let me know when you're ready.
Can you also add a test case that verifies that command => variable => command works?
FOO=$(echo bar)
BAR-$(echo $FOO)
Should equal
FOO=bar
BAR=bar
:turtle: :turtle: :turtle:
@bkeepers this PR is ready to be merged. Context. Kamal released a new version that includes the backward compatibility fix which this PR was waiting for.
@bkeepers ping
@bkeepers ping ping