diff -r 829117ae2e55 Lib/subprocess.py --- a/Lib/subprocess.py Tue Jul 19 16:46:09 2016 -0500 +++ b/Lib/subprocess.py Thu Jul 21 14:41:48 2016 +0200 @@ -847,6 +847,7 @@ _PLATFORM_DEFAULT_CLOSE_FDS = object() +_UNIX_SHELL = None class Popen(object): @@ -1466,7 +1467,15 @@ args = list(args) if shell: - args = ["/bin/sh", "-c"] + args + global _UNIX_SHELL + if _UNIX_SHELL is None: + _UNIX_SHELL = '/bin/sh' + if not os.path.exists(_UNIX_SHELL): + import sysconfig + # On Android the default shell is at '/system/bin/sh'. + if sysconfig.get_config_var('ANDROID_API_LEVEL'): + _UNIX_SHELL = '/system/bin/sh' + args = [_UNIX_SHELL, "-c"] + args if executable: args[0] = executable