git: escape string values in configuration
This should handle the special characters that typically occur. Fixes #1206
This commit is contained in:
parent
8b82f52e75
commit
642d9ffe24
6 changed files with 42 additions and 30 deletions
|
|
@ -19,9 +19,19 @@ let
|
|||
else
|
||||
''${section} "${subsection}"'';
|
||||
|
||||
mkValueString = v:
|
||||
let
|
||||
escapedV = ''
|
||||
"${
|
||||
replaceStrings [ "\n" " " ''"'' "\\" ] [ "\\n" "\\t" ''\"'' "\\\\" ] v
|
||||
}"'';
|
||||
in generators.mkValueStringDefault { } (if isString v then escapedV else v);
|
||||
|
||||
# generation for multiple ini values
|
||||
mkKeyValue = k: v:
|
||||
let mkKeyValue = generators.mkKeyValueDefault { } " = " k;
|
||||
let
|
||||
mkKeyValue =
|
||||
generators.mkKeyValueDefault { inherit mkValueString; } " = " k;
|
||||
in concatStringsSep "\n" (map (kv: " " + mkKeyValue kv) (toList v));
|
||||
|
||||
# converts { a.b.c = 5; } to { "a.b".c = 5; } for toINI
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue