summaryrefslogtreecommitdiffstats
path: root/lib/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/default.nix')
-rw-r--r--lib/default.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/default.nix b/lib/default.nix
index ae1cef9..3ebefdc 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -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;