Skip to content

Commit

Permalink
Don't pollute the environment with OVM details (_OVM_*).
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chu committed Jan 25, 2019
1 parent 51444af commit b171b21
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
1 change: 0 additions & 1 deletion Python-2.7.13/Modules/main.c
Expand Up @@ -334,7 +334,6 @@ Ovm_Main(int argc, char **argv)
cf.cf_flags = 0;

setenv("_OVM_IS_BUNDLE", "1", 1); // for .zip resources
setenv("_OVM_DEPS", "1", 1); // for debug imports

// Communicate C build configuration to Python env.
// TODO: Could rename back to _OVM_HAVE_READLINE.
Expand Down
1 change: 1 addition & 0 deletions core/process.py
Expand Up @@ -378,6 +378,7 @@ def Exec(self, argv, environ):
line.startswith('#!/usr/bin/env bash')):
log('Running %s with OSH', argv)
argv = ['/usr/local/bin/osh'] + argv
#argv = ['python', '/home/andy/git/oilshell/oil/bin/oil.py', 'osh'] + argv
else:
log('%s has line %r', argv, line)
finally:
Expand Down
8 changes: 7 additions & 1 deletion core/util.py
Expand Up @@ -209,11 +209,17 @@ def GetResourceLoader():
# Ovm_Main in main.c sets this.
if posix.environ.get('_OVM_IS_BUNDLE') == '1':
ovm_path = posix.environ.get('_OVM_PATH')
#log('! OVM_PATH = %s', ovm_path)
_loader = _ZipResourceLoader(ovm_path)

# Now clear them so we don't pollute the environment. In Python, this
# calls unsetenv().
del posix.environ['_OVM_IS_BUNDLE']
del posix.environ['_OVM_PATH']

elif posix.environ.get('_OVM_RESOURCE_ROOT'): # Unit tests set this
root_dir = posix.environ.get('_OVM_RESOURCE_ROOT')
_loader = _FileResourceLoader(root_dir)

else:
# NOTE: This assumes all unit tests are one directory deep, e.g.
# core/util_test.py.
Expand Down
7 changes: 7 additions & 0 deletions spec/command_.test.sh
Expand Up @@ -20,3 +20,10 @@ $TMP/not-a-dir/text-file
## status: 127
## OK dash status: 2
## OK bash status: 126

#### External programs don't have _OVM in environment
# bug fix for leakage
env | grep _OVM
echo status=$?
## stdout: status=1

0 comments on commit b171b21

Please sign in to comment.