From 473dc16b2b7e45368c8b6493fdac070f553b4525 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 21 Jun 2017 16:48:48 +0200 Subject: [PATCH] Mark env_var_node as changing exports if it unexports an exported var Fixes #2611 (hopefully). --- src/env.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/env.cpp b/src/env.cpp index ef633e13a..3bdbdd348 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -118,7 +118,8 @@ class env_node_t { /// in the stack are invisible. If new_scope is set for the global variable node, the universe /// will explode. bool new_scope; - /// Does this node contain any variables which are exported to subshells. + /// Does this node contain any variables which are exported to subshells + /// or does it redefine any variables to not be exported? bool exportv = false; /// Pointer to next level. std::unique_ptr next; @@ -1109,6 +1110,9 @@ int env_set(const wcstring &key, const wchar_t *val, env_mode_flags_t var_mode) has_changed_new = true; } else { entry.exportv = false; + // Set the node's exportv when it changes something about exports + // (also when it redefines a variable to not be exported). + node->exportv = has_changed_old != has_changed_new; } if (has_changed_old || has_changed_new) vars_stack().mark_changed_exported();