Skip to content

Commit 1e49b30

Browse files
authored
Merge pull request #164068 from cab404/master
os-release: preserve fields from being excessively quoted
2 parents e543cbb + 0c68e23 commit 1e49b30

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

nixos/modules/misc/version.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ let
88
concatStringsSep mapAttrsToList toLower
99
literalExpression mkRenamedOptionModule mkDefault mkOption trivial types;
1010

11+
needsEscaping = s: null != builtins.match "[a-zA-Z0-9]+" s;
12+
escapeIfNeccessary = s: if needsEscaping s then s else ''"${lib.escape [ "\$" "\"" "\\" "\`" ] s}"'';
1113
attrsToText = attrs:
12-
concatStringsSep "\n" (mapAttrsToList (n: v: ''${n}="${toString v}"'') attrs);
14+
concatStringsSep "\n" (
15+
mapAttrsToList (n: v: ''${n}=${escapeIfNeccessary (toString v)}'') attrs
16+
);
1317

1418
in
1519
{

0 commit comments

Comments
 (0)