Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Feb 2018 17:01:21 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329590 - head/stand/lua
Message-ID:  <201802191701.w1JH1LY9019393@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Feb 19 17:01:21 2018
New Revision: 329590
URL: https://svnweb.freebsd.org/changeset/base/329590

Log:
  stand/lua: Restore environment upon config reload
  
  This restores environment to whatever defaults we had coming into lualoader.

Modified:
  head/stand/lua/config.lua

Modified: head/stand/lua/config.lua
==============================================================================
--- head/stand/lua/config.lua	Mon Feb 19 16:59:28 2018	(r329589)
+++ head/stand/lua/config.lua	Mon Feb 19 17:01:21 2018	(r329590)
@@ -34,6 +34,20 @@ config.env_restore = {};
 
 local modules = {};
 
+function config.restoreEnv()
+	for k, v in pairs(config.env_changed) do
+		local restore_value = config.env_restore[k];
+		if (restore_value ~= nil) then
+			loader.setenv(k, restore_value);
+		else
+			loader.unsetenv(k);
+		end
+	end
+
+	config.env_changed = {};
+	config.env_restore = {};
+end
+
 function config.setenv(k, v)
 	-- Do we need to track this change?
 	if (config.env_changed[k] == nil) then
@@ -391,6 +405,7 @@ function config.reload(file)
 	-- XXX TODO: We should be doing something more here to clear out env
 	-- changes that rode in with the last configuration load
 	modules = {};
+	config.restoreEnv();
 	config.load(file);
 end
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802191701.w1JH1LY9019393>