mirror of
https://cgit.krebsco.de/krops/
synced 2025-01-24 17:16:05 +00:00
lib: add shell.quote
This commit is contained in:
parent
e8505f71ff
commit
50868155fd
@ -51,6 +51,16 @@ let {
|
||||
path = default "/var/src" /* no default? */ (elemAt' parse 6);
|
||||
};
|
||||
|
||||
shell = let
|
||||
isSafeChar = lib.testString "[-+./0-9:=A-Z_a-z]";
|
||||
quoteChar = c:
|
||||
if isSafeChar c then c
|
||||
else if c == "\n" then "'\n'"
|
||||
else "\\${c}";
|
||||
in {
|
||||
quote = x: if x == "" then "''" else lib.stringAsChars quoteChar x;
|
||||
};
|
||||
|
||||
test = re: x: lib.isString x && lib.testString re x;
|
||||
testString = re: x: lib.match re x != null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user