From 29129bf88805ecf467d828271901ce8af800358c Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Fri, 25 Apr 2025 14:34:45 +0200 Subject: [PATCH] Return error on `/time ` Fixes: 9c2b3f6579 ("Re-factor `cmd_time()`") Signed-off-by: Steffen Jaeckel --- src/command/cmd_funcs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c index 7bc19040..10cef531 100644 --- a/src/command/cmd_funcs.c +++ b/src/command/cmd_funcs.c @@ -5314,7 +5314,8 @@ cmd_time(ProfWin* window, const char* const command, gchar** args) }; gboolean redraw = FALSE; gboolean set_all = g_strcmp0(args[0], "all") == 0; - for (size_t n = 0; n < ARRAY_SIZE(time_prefs); ++n) { + size_t n = 0; + for (; n < ARRAY_SIZE(time_prefs); ++n) { if (!set_all && g_strcmp0(args[0], time_prefs[n].name) != 0) continue; const struct time_preferences* tp = &time_prefs[n]; @@ -5355,6 +5356,9 @@ cmd_time(ProfWin* window, const char* const command, gchar** args) return TRUE; } } + if (!set_all && n == ARRAY_SIZE(time_prefs)) { + cons_bad_cmd_usage(command); + } if (redraw) ui_redraw(); return TRUE;