diff options
author | Todd Leonhardt <todd.leonhardt@gmail.com> | 2018-09-12 12:49:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-12 12:49:19 -0400 |
commit | b50d41913d31a735c3d02c532ce4ca45f1b04a46 (patch) | |
tree | 5ad1abdec65dc79317c1de6b064221a148d677a4 | |
parent | f3cd0981f3c0b381f3ca76cc1d5e773cd85dbeae (diff) | |
parent | a66f8e8555d6ae1cba5f4a36226b769408ccd931 (diff) | |
download | cmd2-git-b50d41913d31a735c3d02c532ce4ca45f1b04a46.tar.gz |
Merge pull request #513 from python-cmd2/sane
Moved code from deprecated postparsing_postcmd into _run_cmdfinalizion_hooks
-rw-r--r-- | cmd2/cmd2.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index cc656e01..fb929078 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -1701,12 +1701,6 @@ class Cmd(cmd.Cmd): :param stop: bool - True implies the entire application should exit. :return: bool - True implies the entire application should exit. """ - if not sys.platform.startswith('win'): - # Fix those annoying problems that occur with terminal programs like "less" when you pipe to them - if self.stdin.isatty(): - import subprocess - proc = subprocess.Popen(shlex.split('stty sane')) - proc.communicate() return stop def parseline(self, line: str) -> Tuple[str, str, str]: @@ -1801,6 +1795,14 @@ class Cmd(cmd.Cmd): def _run_cmdfinalization_hooks(self, stop: bool, statement: Optional[Statement]) -> bool: """Run the command finalization hooks""" + + if not sys.platform.startswith('win'): + # Fix those annoying problems that occur with terminal programs like "less" when you pipe to them + if self.stdin.isatty(): + import subprocess + proc = subprocess.Popen(shlex.split('stty sane')) + proc.communicate() + try: data = plugin.CommandFinalizationData(stop, statement) for func in self._cmdfinalization_hooks: |