summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2015-03-17 07:47:09 +0100
committertv <tv@krebsco.de>2015-05-19 23:10:57 +0200
commit879f0b21d3be6e23be7092b04e970b5ec710370b (patch)
tree6f15d4a090b495b0cc248d63c71b0a869afc7acf /lib
parent7fe0cff46a59726287501a34101756e89f67f249 (diff)
lib shell-escape: use builtins.match
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/default.nix b/lib/default.nix
index c1663a7..995e3db 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}");
+
}