zsh: escape double-quoted values

The zsh value renderer emits strings in double quotes so session variables can still expand references such as $HOME. Embedded quotes, backslashes, and backticks were not escaped, which could corrupt generated zsh code or trigger command substitution.

Escape those double-quote-sensitive characters while preserving dollar expansion for existing session-variable semantics.
This commit is contained in:
Austin Horstman
2026-05-18 15:29:56 -05:00
parent 3e17edd5e6
commit c7c139f742
2 changed files with 9 additions and 1 deletions

View File

@@ -14,6 +14,11 @@
home = "$HOME/Documents";
quoted = ''/tmp/with "quotes"'';
};
localVariables = {
BACKTICK = "`literal`";
QUOTED = ''value "quoted"'';
RUNTIME = "$HOME/bin";
};
initContent = lib.mkMerge [
(lib.mkBefore ''
@@ -54,6 +59,9 @@
HELPDIR="@zsh@/share/zsh/$ZSH_VERSION/help"
BACKTICK="\`literal\`"
QUOTED="value \"quoted\""
RUNTIME="$HOME/bin"
autoload -U compinit && compinit
# History options should be set in .zshrc and after oh-my-zsh sourcing.
# See https://github.com/nix-community/home-manager/issues/177.