From a924cea2dfdbb4f8c70dc85bede2cd8b3ebd8307 Mon Sep 17 00:00:00 2001 From: Michael Tolly Date: Mon, 20 Oct 2014 15:03:34 -0500 Subject: [PATCH] Implement setting environment variables --- src/environment.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/environment.js b/src/environment.js index bbb8eb1..95e8d45 100644 --- a/src/environment.js +++ b/src/environment.js @@ -143,6 +143,25 @@ function h$getenv(name, name_off) { return null; } +function h$putenv(name, name_off) { + TRACE_ENV("putenv"); +#ifndef GHCJS_BROWSER + if(h$isNode) { + var nv = h$decodeUtf8z(name, name_off).split('=', 2); + if(nv.length !== 2) return 0; + var n = nv[0]; + var v = nv[1]; + if (v !== '') { + process.env[n] = v; + } + else { + delete process.env[n]; + } + } +#endif + return 0; +} + function h$errorBelch() { h$log("### errorBelch: do we need to handle a vararg function here?"); }