diff --git a/be/cli.py b/be/cli.py index a5be55f..ae92761 100644 --- a/be/cli.py +++ b/be/cli.py @@ -525,6 +525,7 @@ def activate(): os.path.dirname(__file__), "_autocomplete.sh").replace("\\", "/") context.pop("BE_ACTIVE") + context.pop("BE_ACTIVE") sys.exit(subprocess.call(cmd, env=context)) diff --git a/be/lib.py b/be/lib.py index 97be00c..c0e5a15 100644 --- a/be/lib.py +++ b/be/lib.py @@ -109,6 +109,19 @@ def cmd(parent): def context(project): + """Produce the be environment + + The environment is an exact replica of the active + environment of the current process, with a few + additional variables, all of which are listed below. + + The `be` environment are considered "defaults" that + may be overwritten by the incoming environment, with + the exception of BE_CWD which must always be the + real current working directory. + + """ + environment = { "BE_PROJECT": project, "BE_ALIASDIR": "", @@ -133,7 +146,12 @@ def context(project): "BE_TABCOMPLETION": "" } - environment.update(os.environ) + # Do not overwrite BE_CWD + # from incoming environment. + environ = os.environ.copy() + environ.pop("BE_CWD", None) + + environment.update(environ) return environment