summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd2.py b/cmd2.py
index b04bf215..66e4716f 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -1143,7 +1143,16 @@ class Cmd(cmd.Cmd):
"""Execute a command as if at the OS prompt.
Usage: shell <command> [arguments]"""
- os.system(command)
+ try:
+ out = subprocess.check_output(shlex.split(command))
+ except subprocess.CalledProcessError as e:
+ self.perror(e, traceback_war=False)
+ except FileNotFoundError as e:
+ self.perror(e, traceback_war=False)
+ else:
+ if six.PY3:
+ out = out.decode()
+ self.stdout.write(out + '\n')
def path_complete(self, text, line, begidx, endidx, dir_exe_only=False, dir_only=False):
"""Method called to complete an input line by local file system path completion.