}
if (n == null) {
throw new NotFoundException(cmdId);
}
CommandContext ctx = commandContext;
Command cmd;
if (n instanceof CommandNode) {
cmd = lookup(((CommandNode) n).getId());
} else if (n instanceof GroupNode) {
cmd = new GroupCommand(cmdId, (GroupNode) n);
} else if (n instanceof AliasNode) {
cmd = lookup(((AliasNode) n).getCommand().substring(ALIAS_PREFIX.length()));
} else {
throw new IllegalStateException("Unrecognized node type: " + n.getClass().getName());
}
return cmd.execute(ctx, Arguments.shift(objects));
} finally {
env.getVariables().unset(CURRENT_NODE);
}
}
return SUCCESS;