nixpkgs.lib: Add escapeNixString

release-18.03-flake
Ryan Trinkle 2017-12-02 13:03:40 -05:00
parent 7d27f25582
commit 6281eb123b
1 changed files with 8 additions and 0 deletions

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: