diff --git a/src/commands/cmdhandler.py b/src/commands/cmdhandler.py index ff6ec584bb..11c53b3243 100644 --- a/src/commands/cmdhandler.py +++ b/src/commands/cmdhandler.py @@ -401,7 +401,10 @@ def cmdhandler(called_by, raw_string, _testing=False, callertype="session", sess setattr(cmd, key, val) # pre-command hook - yield cmd.at_pre_cmd() + abort = yield cmd.at_pre_cmd() + if abort: + # abort sequence + returnValue(abort) # Parse and execute yield cmd.parse() diff --git a/src/commands/command.py b/src/commands/command.py index c37eb0bd5d..43cf87a4a2 100644 --- a/src/commands/command.py +++ b/src/commands/command.py @@ -255,7 +255,9 @@ class Command(object): def at_pre_cmd(self): """ - This hook is called before self.parse() on all commands + This hook is called before self.parse() on all commands. + If this hook returns anything but False/None, the command + sequence is aborted. """ pass