All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Collin Walling <walling@linux.ibm.com>
Cc: qemu-devel@nongnu.org, armbru@redhat.com, stzi@linux.ibm.com,
	eblake@redhat.com
Subject: Re: [Qemu-devel] [PATCH v2] monitor: print message when using 'help' with an unknown command
Date: Wed, 8 Aug 2018 20:00:24 +0100	[thread overview]
Message-ID: <20180808190023.GN2734@work-vm> (raw)
In-Reply-To: <1532115624-27568-1-git-send-email-walling@linux.ibm.com>

* Collin Walling (walling@linux.ibm.com) wrote:
> When typing 'help' followed by an unknown command, QEMU will
> not print anything to the command line to let the user know
> they typed a bad command. Let's fix this by printing a message
> to the monitor when this happens. For example:
> 
>     (qemu) help xyz
>     unknown command: 'xyz'
> 
> Reported-by: Stefan Zimmermann <stzi@linux.ibm.com>
> Signed-off-by: Collin Walling <walling@linux.ibm.com>

Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  monitor.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 7af1f18..deeb41c 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1013,6 +1013,7 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>                            char **args, int nb_args, int arg_index)
>  {
>      const mon_cmd_t *cmd;
> +    size_t i;
>  
>      /* No valid arg need to compare with, dump all in *cmds */
>      if (arg_index >= nb_args) {
> @@ -1034,9 +1035,15 @@ static void help_cmd_dump(Monitor *mon, const mon_cmd_t *cmds,
>              } else {
>                  help_cmd_dump_one(mon, cmd, args, arg_index);
>              }
> -            break;
> +            return;
>          }
>      }
> +
> +    /* Command not found */
> +    monitor_printf(mon, "unknown command: '");
> +    for (i = 0; i <= arg_index; i++) {
> +        monitor_printf(mon, "%s%s", args[i], i == arg_index ? "'\n" : " ");
> +    }
>  }
>  
>  static void help_cmd(Monitor *mon, const char *name)
> -- 
> 2.7.4
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

  reply	other threads:[~2018-08-08 19:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 19:40 [Qemu-devel] [PATCH v2] monitor: print message when using 'help' with an unknown command Collin Walling
2018-08-08 19:00 ` Dr. David Alan Gilbert [this message]
2018-09-06 18:09   ` Collin Walling
2018-09-06 19:28     ` Dr. David Alan Gilbert
2018-09-06 20:35       ` Collin Walling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180808190023.GN2734@work-vm \
    --to=dgilbert@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stzi@linux.ibm.com \
    --cc=walling@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.