summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-07-02 12:03:53 -0400
committerGitHub <noreply@github.com>2017-07-02 12:03:53 -0400
commit02f234fc6af3e5c2d1434f1a8d52f808ff795dd4 (patch)
treea4c7489d7d2f96a588b2d262f844038e9414acbd /cmd2.py
parent26743a702afa42ff199614def9f7c5eb04308f76 (diff)
parent91fc975ba2bf0414624aa9c263ddf441beadfa3d (diff)
downloadcmd2-git-02f234fc6af3e5c2d1434f1a8d52f808ff795dd4.tar.gz
Merge pull request #163 from python-cmd2/refactor_shell
Refactor shell command
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/cmd2.py b/cmd2.py
index b04bf215..87a28cd2 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -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.