diff --git a/IPython/utils/_process_common.py b/IPython/utils/_process_common.py index ce2c19e..9ede30d 100644 --- a/IPython/utils/_process_common.py +++ b/IPython/utils/_process_common.py @@ -17,6 +17,7 @@ of subprocess utilities, and it contains tools that are common to all of them. import subprocess import shlex import sys +import os from IPython.utils import py3compat @@ -69,7 +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), + # 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,