Skip to contentSkip to conversation

monitor: print message when using 'help' with an unknown command

PATCH In review Collin Walling 2 participants 5 messages Jul 20, 2018 – Sep 6, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 monitor: print message when using 'help' with an unknown command

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'

---
 monitor.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
monitor.c +8 -1
index 7af1f18..deeb41c 100644
@@ -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)
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 10 lines · * Collin Walling ([email protected]) 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'

Quoted 36 lines
---
 monitor.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
monitor.c +8 -1
index 7af1f18..deeb41c 100644
@@ -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)
Signature · 1 line
2.7.4

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#2 lore raw
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Collin Walling ([email protected]) 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:

Quoted 8 lines
Quoted 5 lines

(qemu) help xyz
unknown command: 'xyz'

Thank you for the R-b.

And pardon my impatience, but any chance this patch might get picked up, or does it require some more review first?

[...]

Signature · 2 lines
Respectfully,
- Collin Walling
#3 lore raw
Quoted 13 lines · * Collin Walling ([email protected]) wrote:
Quoted 12 lines · Dr. David Alan Gilbert
Quoted 10 lines · * Collin Walling ([email protected]) 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'

Quoted 7 lines
Quoted 2 lines

Thank you for the R-b.

And pardon my impatience, but any chance this patch might get picked up, or does it require some more review first?

It will on my next HMP pull; it's just not many pulls are happening at the moment; it should be in by the end of the month.

Dave

Quoted 7 lines

[...]

Signature · 2 lines
Respectfully,
- Collin Walling

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#4 lore raw
Quoted 19 lines · Dr. David Alan Gilbert
Quoted 18 lines · * Collin Walling ([email protected]) wrote:
Quoted 6 lines · Dr. David Alan Gilbert
Quoted 5 lines · * Collin Walling ([email protected]) 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:

Quoted 8 lines
Quoted 5 lines

(qemu) help xyz
unknown command: 'xyz'

Thank you for the R-b.

Quoted 7 lines
Quoted 2 lines

And pardon my impatience, but any chance this patch might get picked up, or does it require some more review first?

It will on my next HMP pull; it's just not many pulls are happening at the moment; it should be in by the end of the month.

Dave

Fair enough. Thank you for the update.

Quoted 11 lines
Quoted 8 lines

[...]

Signature · 2 lines
Respectfully,
- Collin Walling

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

Signature · 2 lines
Respectfully,
- Collin Walling