diff options
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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. |