{tv/4lib shell-escape,krebs/4lib/shell.nix escape}
This commit is contained in:
parent
0714ed3ea6
commit
015720ef89
|
@ -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
15
krebs/4lib/shell.nix
Normal 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}");
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue