You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub鈥檚 verified signature.
feat: support escaping $ in variable expansion (#491)
"$" can now be escaped by adding a second "$$". For example, "$$FOO"
will expand to "$FOO".
Go's os.Expand does not natively support escaping $, so we must do it
ourselves. This can normally be done by adding a case for "$" and
returning back "$", effectively collapsing "$$" into "$". However,
because Hermit calls os.Expand repeatedly until no more expansion
occurs, and because Hermit expands environment variables from packages
twice, we need a slightly more complex solution.
By having the environment mapping turn "$" into "$$", these escaped
dollar signs can remain the same. For non-envar expansion, we can simply
call strings.ReplaceAll(str, "$$", "$"). For envars, we employ the naive
method mentioned earlier on the *second* round of expansions.
Fixes #486
---------
Co-authored-by: Sutina Wipawiwat <wsutina@gmail.com>