shithub: mc

Download patch

ref: 13433d8aa8f5e97e4754916a70e177ff14214cfd
parent: 81dd01c05a820dbbfb0fe2cb720d90de26282e62
author: Ori Bernstein <[email protected]>
date: Tue Sep 23 12:35:16 EDT 2014

Add 'getenvv' function.

    Returns an environment variable, with a default value.

--- a/libstd/env.myr
+++ b/libstd/env.myr
@@ -5,7 +5,8 @@
 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 @@
 	-> `None
 }
 
+const getenvv = {name, default
+	match getenv(name)
+	| `Some v:	-> v
+	| `None:	-> default
+	;;
+}