misc/run-with-pythonpath.py: exec() the child (on unix), to remove the intermediate...
authorBrian Warner <warner@lothar.com>
Mon, 1 Jun 2009 21:01:37 +0000 (14:01 -0700)
committerBrian Warner <warner@lothar.com>
Mon, 1 Jun 2009 21:01:37 +0000 (14:01 -0700)
misc/run-with-pythonpath.py

index e23a15de7390614eab4b05fcb291f1e793268cd1..d402f7c5e77b7faec51607db8166cde2add5b7c5 100644 (file)
@@ -34,6 +34,17 @@ if oldpp == [""]:
 newpp = os.pathsep.join(oldpp + [supportlib,])
 os.environ['PYTHONPATH'] = newpp
 
-command = sys.argv[1:]
-rc = subprocess.call(command)
-sys.exit(rc)
+if sys.platform == "win32":
+    command = sys.argv[1:]
+    rc = subprocess.call(command)
+    sys.exit(rc)
+else:
+    from twisted.python.procutils import which
+    cmd = sys.argv[1]
+    if cmd and cmd[0] not in "/~.":
+        cmds = which(cmd)
+        if not cmds:
+            print >>sys.stderr, "'%s' not found on PATH" % (cmd,)
+            sys.exit(-1)
+        cmd = cmds[0]
+    os.execve(cmd, sys.argv[1:], os.environ)