use system_raw in terminal, even on Windows #979

Merged
merged 2 commits into from Nov 11, 2011
View
13 IPython/core/interactiveshell.py
@@ -2075,10 +2075,21 @@ def system_raw(self, cmd):
cmd : str
Command to execute.
"""
+ cmd = self.var_expand(cmd, depth=2)
+ # protect os.system from UNC paths on Windows, which it can't handle:
+ if sys.platform == 'win32':
+ from IPython.utils._process_win32 import AvoidUNCPath
+ with AvoidUNCPath() as path:
+ if path is not None:
+ cmd = '"pushd %s &&"%s' % (path, cmd)
+ ec = os.system(cmd)
+ else:
+ ec = os.system(cmd)
+
# We explicitly do NOT return the subprocess status code, because
# a non-None value would trigger :func:`sys.displayhook` calls.
# Instead, we store the exit_code in user_ns.
- self.user_ns['_exit_code'] = os.system(self.var_expand(cmd, depth=2))
+ self.user_ns['_exit_code'] = ec
# use piped system by default, because it is better behaved
system = system_piped
View
8 IPython/frontend/terminal/interactiveshell.py
@@ -112,11 +112,9 @@ def __init__(self, config=None, ipython_dir=None, profile_dir=None, user_ns=None
config=config, profile_dir=profile_dir, user_ns=user_ns,
user_global_ns=user_global_ns, custom_exceptions=custom_exceptions
)
- # use os.system instead of utils.process.system by default, except on Windows
- if os.name == 'nt':
- self.system = self.system_piped
- else:
- self.system = self.system_raw
+ # use os.system instead of utils.process.system by default,
+ # because piped system doesn't make sense in the Terminal:
+ self.system = self.system_raw
self.init_term_title()
self.init_usage(usage)