Permalink
Browse files

Merge pull request #979 from minrk/windows/system_raw

use system_raw in terminal, even on Windows

system_raw uses os.system instead of utils.process.system, and makes more sense in a Terminal session.
  • Loading branch information...
2 parents 467b5b2 + e02b493 commit cfae6329b7ada151a78444946400498bbf3890db @fperez fperez committed Nov 11, 2011
Showing with 15 additions and 6 deletions.
  1. +12 −1 IPython/core/interactiveshell.py
  2. +3 −5 IPython/frontend/terminal/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
@@ -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)

0 comments on commit cfae632

Please sign in to comment.