Return error on /time <invalid-section>

Fixes: 9c2b3f6579 ("Re-factor `cmd_time()`")

Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
Steffen Jaeckel
2025-04-25 14:34:45 +02:00
parent 4194298dbd
commit 29129bf888

View File

@@ -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;