{tv/4lib shell-escape,krebs/4lib/shell.nix escape}

This commit is contained in:
tv 2015-08-28 20:09:54 +02:00
parent 0714ed3ea6
commit 015720ef89
3 changed files with 17 additions and 8 deletions

View file

@ -14,5 +14,6 @@ builtins // lib // rec {
dns = import ./dns.nix { inherit lib; };
listset = import ./listset.nix { inherit lib; };
shell = import ./shell.nix { inherit lib; };
tree = import ./tree.nix { inherit lib; };
}

15
krebs/4lib/shell.nix Normal file
View file

@ -0,0 +1,15 @@
{ lib, ... }:
with builtins;
with lib;
rec {
escape =
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}");
}

View file

@ -16,12 +16,5 @@ krebs // rec {
# "7.4.335" -> "74"
majmin = with lib; x : concatStrings (take 2 (splitString "." x));
shell-escape =
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}");
shell-escape = krebs.shell.escape;
}