Index: Lib/subprocess.py =================================================================== --- Lib/subprocess.py (revision 82816) +++ Lib/subprocess.py (working copy) @@ -1091,6 +1091,8 @@ if shell: args = ["/bin/sh", "-c"] + args + if executable: + args[0] = executable if executable is None: executable = args[0] Index: Lib/test/test_subprocess.py =================================================================== --- Lib/test/test_subprocess.py (revision 82816) +++ Lib/test/test_subprocess.py (working copy) @@ -641,6 +641,14 @@ os.remove(fname) self.assertEqual(rc, 47) + def test_specific_shell(self): + # Issue #9265: Incorrect name passed as arg[0]. + for sh in ["/bin/sh", "/bin/bash", "/bin/ksh"]: + if os.path.isfile(sh): + p = subprocess.Popen("echo $0", executable=sh, shell=True, + stdout=subprocess.PIPE) + self.assertEqual(p.stdout.read().strip(), sh) + def _kill_process(self, method, *args): # Do not inherit file handles from the parent. # It should fix failures on some platforms.