tangled
alpha
login
or
join now
tjh.dev
/
nixpkgs
Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
0
fork
atom
overview
issues
pulls
pipelines
nixpkgs.lib: Add escapeNixString
Ryan Trinkle
8 years ago
6281eb12
7d27f255
+8
1 changed file
expand all
collapse all
unified
split
lib
strings.nix
+8
lib/strings.nix
···
219
219
*/
220
220
escapeShellArgs = concatMapStringsSep " " escapeShellArg;
221
221
222
222
+
/* Turn a string into a Nix expression representing that string
223
223
+
224
224
+
Example:
225
225
+
escapeNixString "hello\${}\n"
226
226
+
=> "\"hello\\\${}\\n\""
227
227
+
*/
228
228
+
escapeNixString = s: escape ["$"] (builtins.toJSON s);
229
229
+
222
230
/* Obsolete - use replaceStrings instead. */
223
231
replaceChars = builtins.replaceStrings or (
224
232
del: new: s: