diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index d7ec6c8..d8c080b 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2218,7 +2218,8 @@ class InteractiveShell(SingletonConfigurable): self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1)) def system_raw(self, cmd): - """Call the given cmd in a subprocess using os.system + """Call the given cmd in a subprocess using os.system on Windows or + subprocess.call using the system shell on other platforms. Parameters ---------- @@ -2236,11 +2237,12 @@ class InteractiveShell(SingletonConfigurable): ec = os.system(cmd) else: cmd = py3compat.unicode_to_str(cmd) - ec = subprocess.call(cmd, shell=True, executable=os.environ.get('SHELL')) - # The high byte is the exit code, the low byte is a signal number - # that we discard for now. See the docs for os.wait() - if ec > 255: - ec >>= 8 + # Call the cmd using the OS shell, instead of the default /bin/sh, if set. + ec = subprocess.call(cmd, shell=True, executable=os.environ.get('SHELL', None)) + # Returns either the exit code or minus the value of the signal number. + # See the docs for subprocess.Popen.returncode . + if ec < 0: + ec = -ec # We explicitly do NOT return the subprocess status code, because # a non-None value would trigger :func:`sys.displayhook` calls.