mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
lib/zsh: fix shell escaping and integrate formatShellArrayContent
Replace naive string quoting with lib.escapeShellArg for proper shell escaping of special characters, spaces, and quotes. Integrate with new formatShellArrayContent for intelligent multi-line array formatting in zsh array definitions. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
a8dbb4e325
commit
5176d93c0a
3 changed files with 8 additions and 5 deletions
|
|
@ -7,9 +7,12 @@ rec {
|
|||
if builtins.isBool v then
|
||||
if v then "true" else "false"
|
||||
else if builtins.isString v then
|
||||
''"${v}"''
|
||||
lib.escapeShellArg v
|
||||
else if builtins.isList v then
|
||||
"(${lib.concatStringsSep " " (map toZshValue v)})"
|
||||
let
|
||||
shell = import ./shell.nix { inherit lib; };
|
||||
in
|
||||
"(${shell.formatShellArrayContent (map toString v)})"
|
||||
else
|
||||
''"${toString v}"'';
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@
|
|||
assertFileContains home-files/.zshenv \
|
||||
'. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"'
|
||||
assertFileContains home-files/.zshenv \
|
||||
'export FOO="bar"'
|
||||
'export FOO=bar'
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.zshenv
|
||||
assertFileRegex home-files/.zshenv 'export V1="v1"'
|
||||
assertFileRegex home-files/.zshenv 'export V2="v2-v1"'
|
||||
assertFileRegex home-files/.zshenv 'export V1=v1'
|
||||
assertFileRegex home-files/.zshenv 'export V2=v2-v1'
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue