From a59c2b3e03c651bda205de432a074debbf126300 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Mar 2015 07:47:09 +0100 Subject: lib shell-escape: use builtins.match --- lib/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'lib') 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}"); + } -- cgit v1.2.3