summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-18 20:00:39 (GMT)
committerGuido van Rossum <guido@python.org>1997-09-18 20:00:39 (GMT)
commit6dd48686810f4806d98eaffa29e53dfabaca2e08 (patch)
treef051e3c0cb4ea455b291e9fd7889b075c75e40fa /Lib
parent963b871e86bd85b7fb3551fa9fac5363977fc43b (diff)
downloadcpython-6dd48686810f4806d98eaffa29e53dfabaca2e08.zip
cpython-6dd48686810f4806d98eaffa29e53dfabaca2e08.tar.gz
cpython-6dd48686810f4806d98eaffa29e53dfabaca2e08.tar.bz2
The command can now either be a string (as before) or a list of
arguments for execvp (for those who don't want the shell's argument parsing).
Diffstat (limited to 'Lib')
-rw-r--r--Lib/popen2.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/popen2.py b/Lib/popen2.py
index ae89f94..b5defbc 100644
--- a/Lib/popen2.py
+++ b/Lib/popen2.py
@@ -12,7 +12,8 @@ def _cleanup():
class Popen3:
def __init__(self, cmd, capturestderr=0):
- cmd = ['/bin/sh', '-c', cmd]
+ if type(cmd) == type(''):
+ cmd = ['/bin/sh', '-c', cmd]
p2cread, p2cwrite = os.pipe()
c2pread, c2pwrite = os.pipe()
if capturestderr:
@@ -34,7 +35,7 @@ class Popen3:
os.close(i)
except: pass
try:
- os.execv(cmd[0], cmd)
+ os.execvp(cmd[0], cmd)
finally:
os._exit(1)
# Shouldn't come here, I guess
@@ -85,7 +86,7 @@ def _test():
w.close()
assert r.read() == teststr
print "testing popen3..."
- r, w, e = popen3('cat')
+ r, w, e = popen3(['cat'])
w.write(teststr)
w.close()
assert r.read() == teststr