From c9d4dd48a07ba1e3670094bba69efc0768e046e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 9 Nov 2025 18:15:00 +0100 Subject: [PATCH] core: display an error message if the buffer is not found with command `/buffer listvar` --- src/core/core-command.c | 42 +++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/core/core-command.c b/src/core/core-command.c index 84d711cf7..8b9649404 100644 --- a/src/core/core-command.c +++ b/src/core/core-command.c @@ -1286,28 +1286,30 @@ COMMAND_CALLBACK(buffer) ptr_buffer = gui_buffer_search_by_id_number_name (argv[2]); else ptr_buffer = buffer; - - if (ptr_buffer) + if (!ptr_buffer) { - if (ptr_buffer->local_variables - && (ptr_buffer->local_variables->items_count > 0)) - { - gui_chat_printf (NULL, ""); - gui_chat_printf (NULL, - _("Local variables for buffer \"%s\":"), - ptr_buffer->name); - hashtable_map (ptr_buffer->local_variables, - &command_buffer_display_localvar, NULL); - } - else - { - gui_chat_printf (NULL, - _("No local variable defined for buffer " - "\"%s\""), - ptr_buffer->name); - } + gui_chat_printf (NULL, + _("%sBuffer \"%s\" not found"), + gui_chat_prefix[GUI_CHAT_PREFIX_ERROR], + argv[2]); + return WEECHAT_RC_ERROR; + } + if (ptr_buffer->local_variables + && (ptr_buffer->local_variables->items_count > 0)) + { + gui_chat_printf (NULL, ""); + gui_chat_printf (NULL, + _("Local variables for buffer \"%s\":"), + ptr_buffer->name); + hashtable_map (ptr_buffer->local_variables, + &command_buffer_display_localvar, NULL); + } + else + { + gui_chat_printf (NULL, + _("No local variable defined for buffer \"%s\""), + ptr_buffer->name); } - return WEECHAT_RC_OK; }