diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2017-07-02 12:03:53 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-02 12:03:53 -0400 |
commit | 02f234fc6af3e5c2d1434f1a8d52f808ff795dd4 (patch) | |
tree | a4c7489d7d2f96a588b2d262f844038e9414acbd /cmd2.py | |
parent | 26743a702afa42ff199614def9f7c5eb04308f76 (diff) | |
parent | 91fc975ba2bf0414624aa9c263ddf441beadfa3d (diff) | |
download | cmd2-git-02f234fc6af3e5c2d1434f1a8d52f808ff795dd4.tar.gz |
Merge pull request #163 from python-cmd2/refactor_shell
Refactor shell command
Diffstat (limited to 'cmd2.py')
-rwxr-xr-x | cmd2.py | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -479,9 +479,7 @@ class Cmd(cmd.Cmd): self.initial_stdout = sys.stdout self.history = History() self.pystate = {} - # noinspection PyUnresolvedReferences - self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) - if fname.startswith('do_')] + self.keywords = self.reserved_words + [fname[3:] for fname in dir(self) if fname.startswith('do_')] self.parser_manager = ParserManager(redirector=self.redirector, terminators=self.terminators, multilineCommands=self.multilineCommands, legalChars=self.legalChars, commentGrammars=self.commentGrammars, @@ -1138,12 +1136,12 @@ class Cmd(cmd.Cmd): Usage: pause [text]""" sm.input(text + '\n') - # noinspection PyMethodMayBeStatic def do_shell(self, command): """Execute a command as if at the OS prompt. Usage: shell <command> [arguments]""" - os.system(command) + proc = subprocess.Popen(command, stdout=self.stdout, stderr=sys.stderr, shell=True) + proc.communicate() 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. |