summaryrefslogtreecommitdiff
path: root/libstd
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2014-09-23 16:35:16 -0400
committerOri Bernstein <ori@eigenstate.org>2014-09-23 16:35:16 -0400
commit13433d8aa8f5e97e4754916a70e177ff14214cfd (patch)
treead7358c3ddb956ec3b6a9f0d0a972706cd2d03a9 /libstd
parent81dd01c05a820dbbfb0fe2cb720d90de26282e62 (diff)
downloadmc-13433d8aa8f5e97e4754916a70e177ff14214cfd.tar.gz
Add 'getenvv' function.
Returns an environment variable, with a default value.
Diffstat (limited to 'libstd')
-rw-r--r--libstd/env.myr9
1 files changed, 8 insertions, 1 deletions
diff --git a/libstd/env.myr b/libstd/env.myr
index 85bced9..6dd7756 100644
--- a/libstd/env.myr
+++ b/libstd/env.myr
@@ -5,7 +5,8 @@ use "sleq.use"
pkg std =
extern var _environment : byte[:][:]
- const getenv : (name : byte[:] -> std.option(byte[:]))
+ const getenv : (name : byte[:] -> option(byte[:]))
+ const getenvv : (name : byte[:], default : byte[:] -> byte[:])
;;
const getenv = {name
@@ -19,3 +20,9 @@ const getenv = {name
-> `None
}
+const getenvv = {name, default
+ match getenv(name)
+ | `Some v: -> v
+ | `None: -> default
+ ;;
+}