nixpkgs.lib: Add escapeNixString

This commit is contained in:
Ryan Trinkle 2017-12-02 13:03:40 -05:00
parent 7d27f25582
commit 6281eb123b

View File

@ -219,6 +219,14 @@ rec {
*/
escapeShellArgs = concatMapStringsSep " " escapeShellArg;
/* Turn a string into a Nix expression representing that string
Example:
escapeNixString "hello\${}\n"
=> "\"hello\\\${}\\n\""
*/
escapeNixString = s: escape ["$"] (builtins.toJSON s);
/* Obsolete - use replaceStrings instead. */
replaceChars = builtins.replaceStrings or (
del: new: s: