[issue9265] Incorrect name passed as arg[0] when shell=True and executable specified

Narnie Harshoe report at bugs.python.org
Sun Jul 18 21:33:49 CEST 2010


Narnie Harshoe <signuplinux at gmail.com> added the comment:

Hello,

I am impressed by the activity here. I am a new programmer and cutting my teeth with python. I wish I knew how to do a patch and write unit tests, but I'm just not there yet.

I can show a test case in this fashion where it fails.

First I prove that /bin/sh is /bin/sh (er, dash) and /bin/bash is /bin/bash. Then it can be seen that when executable is set as /bin/bash and there is a shell error, that it returns a shell error from /bin/sh, not from /bin/bash.

I see there are patches here that should fix it, but for those wanting to see the buggy code in action, here it is using the fact that echo was mistyped as echos to raise a shell error (but shell=True so it doesn't raise an OSError exception).
_____________________________

in shell terminal:
$ file /bin/bash
/bin/bash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped
$ file /bin/sh
/bin/sh: symbolic link to `dash'
$ file /bin/dash
/bin/dash: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

in python interactive interpreter

>>> shell = Popen('echos', shell=True, executable="/bin/bash", stdin=PIPE, stderr=PIPE, stdout=PIPE)
>>> shell.communicate()
('', '/bin/sh: echos: command not found\n')
>>> shell = Popen('echos', shell=True, executable="/bin/bash", stdin=PIPE, stderr=PIPE, stdout=PIPE)
>>> shell.communicate()
('', '/bin/bash: echos: command not found\n')

Thank you for working on this so quickly. This is truly an amazing community.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9265>
_______________________________________


More information about the Python-bugs-list mailing list