python2.7/subprocess.py Popen on Ubuntu 10.04 Bug
Hi, I found that using Popen with both executable and shell parameters set creates a bug: For example: Calling: Popen(["-a"], exacutable="/bin/ls", shell=True) Exacutes: /bin/ls -c -a instead of: /bin/sh -c "/bin/ls -a" The bug in the function: def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (POSIX version)""" Lines: 1124-1127: if shell: args = ["/bin/sh", "-c"] + args if executable: args[0] = executable Eyal Moscovici Networking and Virtualization Technologies IBM Haifa Research Lab
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 30.10.2013 14:59, schrieb Eyal Moscovici:
Hi,
I found that using Popen with both executable and shell parameters set creates a bug:
For example:
Calling:
Popen(["-a"], exacutable="/bin/ls", shell=True)
Exacutes: /bin/ls -c -a instead of: /bin/sh -c "/bin/ls -a"
The bug in the function: def _execute_child(self, args, executable, preexec_fn, close_fds, cwd, env, universal_newlines, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite): """Execute program (POSIX version)"""
Lines: 1124-1127:
if shell: args = ["/bin/sh", "-c"] + args if executable: args[0] = executable
Hi Eyal, thanks for your report. This is working as documented; if shell is true the "executable" argument specifies a replacement for /bin/sh, not for the command. Also you'll always have to include an executable name in your args as well: Popen('ls -a', shell=True) cheers, Georg -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iEYEARECAAYFAlJ4kPAACgkQN9GcIYhpnLBVAACfUQFDBt5YnbwlX5XWrqOBXSpk vM8Ani4spDk68YckLcIAd5xOoSqPQUzg =Nxrk -----END PGP SIGNATURE-----
participants (2)
-
Eyal Moscovici
-
Georg Brandl