summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2015-03-17 07:47:09 +0100
committertv <tv@shackspace.de>2015-05-19 23:10:57 +0200
commita59c2b3e03c651bda205de432a074debbf126300 (patch)
tree6f15d4a090b495b0cc248d63c71b0a869afc7acf
parent3867e1866a24ce29908dedfee534bbfe93a90c11 (diff)
lib shell-escape: use builtins.match
-rw-r--r--lib/default.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/default.nix b/lib/default.nix
index c1663a7b8..995e3dbcd 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -40,5 +40,12 @@ in
#setToList = setMap (_: v: v);
shell-escape =
- stringAsChars (c: if c == "\n" then ''"${c}"'' else "\\${c}");
+ let
+ isSafeChar = c: match "[-./0-9_a-zA-Z]" c != null;
+ in
+ stringAsChars (c:
+ if isSafeChar c then c
+ else if c == "\n" then "'\n'"
+ else "\\${c}");
+
}