svn commit: r329590 - head/stand/lua

Kyle Evans kevans at FreeBSD.org
Mon Feb 19 17:01:22 UTC 2018


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
 


More information about the svn-src-all mailing list