lib shell-escape: use builtins.match

This commit is contained in:
tv 2015-03-17 07:47:09 +01:00
parent 3867e1866a
commit a59c2b3e03
1 changed files with 8 additions and 1 deletions

View File

@ -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}");
}