oh-my-zsh: preserve shell expansion in custom and theme#9095
oh-my-zsh: preserve shell expansion in custom and theme#9095ooojustin wants to merge 1 commit intonix-community:masterfrom
Conversation
Zocker1999NET
left a comment
There was a problem hiding this comment.
I'm sorry that I haven't thought about the possibility that users might legitimatly use shell variables in this config, otherwise I would have declared my PR as a potential breaking change.
While I'm personally not really for making this behavior explicit, I'm in principle open for discussion that there might be use cases for it.
The example you gave with $HOME seems weird to be, because IMO you can just use ${config.home.homeDirectory} instead. But, as I said, I'm open to accept the possibility that using shell variables instead might has an advantage I do not know yet.
But I'm explicitly against just reverting back to the old behavior because it may break users expectations should they be wanting to refer to a path containing chars like $ or ", because they can also just not use a function like escapeShellArg on their side because this function might escape its input using '', which are then taken literally.
I would even be more open to not escape those config values at all (i.e. remove the surrounding "), document that this behavior is explicit in the options documentations, declare that a breaking change & requesting updating users to escape their values using escapeShellArg.
Another possibility I see is adding a themeRaw option, defaulting theme = escapeShellArg cfg.themeRaw; and using themeRaw in .zshrc instead.
Or expanding escapeShellArg to not escape values which were surrounded by a new rawShellValue function to allow users to opt in to non-escaping that way. But while this would make it easy to port this change to arbitary values, it would require more code & adding more documentation so users know how to use it.
(and of course applying the same to custom resp.)
I agree for that case, and I’m not trying to make shell-variable expansion a new explicit feature. In my case I noticed because I had one of these pointing at a If you’d rather handle this with something more explicit like |
Description
Fixes a regression from #9042.
programs.zsh.oh-my-zsh.customandprograms.zsh.oh-my-zsh.themecurrently useescapeShellArg, which single-quotes values like$HOME/.config/shell.That prevents shell expansion and makes oh-my-zsh look for custom themes and plugins in a literal
$HOME/...path.This switches the generated assignments back to double-quoted shell strings so runtime expansion still works:
ZSH_CUSTOM="..."ZSH_THEME="..."Validation:
zsh-shell-expansion) covering the generated.zshrcoutputnix run .#tests -- zsh-shell-expansionupstream/master.zshrccontains double-quotedZSH_CUSTOM/ZSH_THEMEand that a custom oh-my-zsh theme loads againChecklist
Change is backwards compatible.
Code formatted with
nix fmtornix-shell -A dev --run treefmt.Code tested through
nix run .#tests -- test-allornix-shell --pure tests -A run.all.Test cases updated/added. See example.
Commit messages are formatted like
See CONTRIBUTING for more information and recent commit messages for examples.
If this PR adds a new module
If this PR adds an exciting new feature or contains a breaking change.