Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

nixpkgs.lib: Add escapeNixString

+8
+8
lib/strings.nix
··· 219 219 */ 220 220 escapeShellArgs = concatMapStringsSep " " escapeShellArg; 221 221 222 + /* Turn a string into a Nix expression representing that string 223 + 224 + Example: 225 + escapeNixString "hello\${}\n" 226 + => "\"hello\\\${}\\n\"" 227 + */ 228 + escapeNixString = s: escape ["$"] (builtins.toJSON s); 229 + 222 230 /* Obsolete - use replaceStrings instead. */ 223 231 replaceChars = builtins.replaceStrings or ( 224 232 del: new: s: