summaryrefslogtreecommitdiffstats
path: root/Lib/os.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1995-03-14 17:27:18 (GMT)
committerGuido van Rossum <guido@python.org>1995-03-14 17:27:18 (GMT)
commit030afb1d3a86196be85b51f2174b5796a93eb07d (patch)
treeb0a2d1d4b993f5d35ee6f922031343e648a3bcb1 /Lib/os.py
parentdcce73af48387531e0cef280e27b3689bf7d4b85 (diff)
downloadcpython-030afb1d3a86196be85b51f2174b5796a93eb07d.zip
cpython-030afb1d3a86196be85b51f2174b5796a93eb07d.tar.gz
cpython-030afb1d3a86196be85b51f2174b5796a93eb07d.tar.bz2
add execvpe -- mix of execvp and execve
Diffstat (limited to 'Lib/os.py')
-rw-r--r--Lib/os.py28
1 files changed, 22 insertions, 6 deletions
diff --git a/Lib/os.py b/Lib/os.py
index 5c8f3dc..6de2d0b 100644
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -55,16 +55,32 @@ def execle(file, *args):
def execlp(file, *args):
execvp(file, args)
-_notfound = None
+def execlpe(file, *args):
+ env = args[-1]
+ execvpe(file, args[:-1], env)
+
def execvp(file, args):
+ _execvpe(file, args)
+
+def execvpe(file, args, env):
+ _execvpe(file, args, env)
+
+_notfound = None
+def _execvpe(file, args, env = None):
+ if env:
+ func = execve
+ argrest = (args, env)
+ else:
+ func = execv
+ argrest = (args,)
+ env = environ
global _notfound
head, tail = path.split(file)
if head:
- execv(file, args)
+ apply(func, (file,) + argrest)
return
- ENOENT = 2
- if environ.has_key('PATH'):
- envpath = environ['PATH']
+ if env.has_key('PATH'):
+ envpath = env['PATH']
else:
envpath = defpath
import string
@@ -78,7 +94,7 @@ def execvp(file, args):
for dir in PATH:
fullname = path.join(dir, file)
try:
- execv(fullname, args)
+ apply(func, (fullname,) + argrest)
except error, (errno, msg):
if errno != arg[0]:
exc, arg = error, (errno, msg)