|
50 | 50 | from .argparse_custom import CompletionItem, DEFAULT_ARGUMENT_PARSER |
51 | 51 | from .clipboard import can_clip, get_paste_buffer, write_to_paste_buffer |
52 | 52 | from .decorators import with_argparser |
53 | | -from .exceptions import EmbeddedConsoleExit, EmptyStatement |
| 53 | +from .exceptions import CmdLineError, EmbeddedConsoleExit, EmptyStatement |
54 | 54 | from .history import History, HistoryItem |
55 | 55 | from .parsing import StatementParser, Statement, Macro, MacroArg, shlex_split |
56 | 56 | from .rl_utils import rl_type, RlType, rl_get_point, rl_set_prompt, vt100_support, rl_make_safe_prompt, rl_warning |
@@ -1599,12 +1599,11 @@ def onecmd_plus_hooks(self, line: str, *, add_to_history: bool = True, py_bridge |
1599 | 1599 | stop = False |
1600 | 1600 | try: |
1601 | 1601 | statement = self._input_line_to_statement(line) |
1602 | | - except EmptyStatement: |
| 1602 | + except (EmptyStatement, ValueError) as ex: |
| 1603 | + if isinstance(ex, ValueError): |
| 1604 | + # Since shlex.split() failed on syntax, let user know what's going on |
| 1605 | + self.perror("Invalid syntax: {}".format(ex)) |
1603 | 1606 | return self._run_cmdfinalization_hooks(stop, None) |
1604 | | - except ValueError as ex: |
1605 | | - # If shlex.split failed on syntax, let user know what's going on |
1606 | | - self.pexcept("Invalid syntax: {}".format(ex)) |
1607 | | - return stop |
1608 | 1607 |
|
1609 | 1608 | # now that we have a statement, run it with all the hooks |
1610 | 1609 | try: |
@@ -1684,8 +1683,8 @@ def onecmd_plus_hooks(self, line: str, *, add_to_history: bool = True, py_bridge |
1684 | 1683 | # Stop saving command's stdout before command finalization hooks run |
1685 | 1684 | self.stdout.pause_storage = True |
1686 | 1685 |
|
1687 | | - except EmptyStatement: |
1688 | | - # don't do anything, but do allow command finalization hooks to run |
| 1686 | + except (CmdLineError, EmptyStatement): |
| 1687 | + # Don't do anything, but do allow command finalization hooks to run |
1689 | 1688 | pass |
1690 | 1689 | except Exception as ex: |
1691 | 1690 | self.pexcept(ex) |
|
0 commit comments