@@ -55,16 +55,32 @@ def execle(file, *args):
5555def execlp (file , * args ):
5656 execvp (file , args )
5757
58- _notfound = None
58+ def execlpe (file , * args ):
59+ env = args [- 1 ]
60+ execvpe (file , args [:- 1 ], env )
61+
5962def execvp (file , args ):
63+ _execvpe (file , args )
64+
65+ def execvpe (file , args , env ):
66+ _execvpe (file , args , env )
67+
68+ _notfound = None
69+ def _execvpe (file , args , env = None ):
70+ if env :
71+ func = execve
72+ argrest = (args , env )
73+ else :
74+ func = execv
75+ argrest = (args ,)
76+ env = environ
6077 global _notfound
6178 head , tail = path .split (file )
6279 if head :
63- execv ( file , args )
80+ apply ( func , ( file ,) + argrest )
6481 return
65- ENOENT = 2
66- if environ .has_key ('PATH' ):
67- envpath = environ ['PATH' ]
82+ if env .has_key ('PATH' ):
83+ envpath = env ['PATH' ]
6884 else :
6985 envpath = defpath
7086 import string
@@ -78,7 +94,7 @@ def execvp(file, args):
7894 for dir in PATH :
7995 fullname = path .join (dir , file )
8096 try :
81- execv ( fullname , args )
97+ apply ( func , ( fullname ,) + argrest )
8298 except error , (errno , msg ):
8399 if errno != arg [0 ]:
84100 exc , arg = error , (errno , msg )
0 commit comments