diff options
author | tv <tv@shackspace.de> | 2015-08-28 20:09:54 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-08-28 20:15:57 +0200 |
commit | 015720ef89b81d3d17b3aa7dcaa1e1489c0f87a8 (patch) | |
tree | 6e9fc6eef15bcff823885181b10579b555379fc1 | |
parent | 0714ed3ea6c889c0576edd8075dc7c2b50d3e8b5 (diff) |
{tv/4lib shell-escape,krebs/4lib/shell.nix escape}
-rw-r--r-- | krebs/4lib/default.nix | 1 | ||||
-rw-r--r-- | krebs/4lib/shell.nix | 15 | ||||
-rw-r--r-- | tv/4lib/default.nix | 9 |
3 files changed, 17 insertions, 8 deletions
diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix index b67585335..8b587dfb2 100644 --- a/krebs/4lib/default.nix +++ b/krebs/4lib/default.nix @@ -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; }; } diff --git a/krebs/4lib/shell.nix b/krebs/4lib/shell.nix new file mode 100644 index 000000000..48b220f87 --- /dev/null +++ b/krebs/4lib/shell.nix @@ -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}"); +} diff --git a/tv/4lib/default.nix b/tv/4lib/default.nix index 352689af4..106535ba2 100644 --- a/tv/4lib/default.nix +++ b/tv/4lib/default.nix @@ -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; } |