nixpkgs.lib: Add escapeNixString
This commit is contained in:
parent
7d27f25582
commit
6281eb123b
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user