From ab23885fd4eb61acab89dfea0c3700950d1df452 2016-05-31 15:01:14 From: Pavol Juhas Date: 2016-05-31 15:01:14 Subject: [PATCH] Run user $SHELL only for shell commands. Do this only for POSIX systems. Use default shell execution on Windows even if SHELL is set in the environment. --- diff --git a/IPython/utils/_process_common.py b/IPython/utils/_process_common.py index 3062975..9ede30d 100644 --- a/IPython/utils/_process_common.py +++ b/IPython/utils/_process_common.py @@ -70,8 +70,14 @@ def process_handler(cmd, callback, stderr=subprocess.PIPE): sys.stderr.flush() # On win32, close_fds can't be true when using pipes for stdin/out/err close_fds = sys.platform != 'win32' - p = subprocess.Popen(cmd, shell=isinstance(cmd, py3compat.string_types), - executable=os.environ.get('SHELL'), + # Determine if cmd should be run with system shell. + shell = isinstance(cmd, py3compat.string_types) + # On POSIX systems run shell commands with user-preferred shell. + executable = None + if shell and os.name == 'posix' and 'SHELL' in os.environ: + executable = os.environ['SHELL'] + p = subprocess.Popen(cmd, shell=shell, + executable=executable, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=stderr,