shithub: mc

Download patch

ref: e26dcd2a475fe909ee4e1bf6120f244e4c0b9d31
parent: 94ee9832f5861c4d09afa12338720eb3a479c342
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Jan 16 19:49:44 EST 2017

Setenv for Plan 9.

--- a/lib/std/env+plan9.myr
+++ b/lib/std/env+plan9.myr
@@ -12,11 +12,13 @@
 use "sleq"
 use "slpush"
 use "slurp"
+use "blat"
 use "threadhooks"
 
 pkg std =
-	const getenv :	(name : byte[:] -> option(byte[:]))
-	const getenvv :	(name : byte[:], default : byte[:] -> byte[:])
+	const getenv	: (name : byte[:] -> option(byte[:]))
+	const getenvv	: (name : byte[:], default : byte[:] -> byte[:])
+	const setenv	: (name : byte[:], val : byte[:] -> void)
 ;;
 
 var envkey 	: byte[:][:]
@@ -63,4 +65,12 @@
 	| `Some val:	-> val
 	| `None:	-> default
 	;;
+}
+
+const setenv = {name, val
+	var p
+
+	p = fmt("/env/{}", name)
+	blat(p, val, 0o644)
+	slfree(p)
 }