From b74af1d2daa3bb597164d292021f367716b9e0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 22 May 2021 08:27:27 +0200 Subject: [PATCH] core: split startup command before evaluating it (issue #1643) --- ChangeLog.adoc | 1 + src/core/wee-command.c | 22 ++++++++++------------ src/core/wee-config.c | 10 ++++++---- src/core/weechat.c | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 7e1b3506e..9d1e4f69b 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -45,6 +45,7 @@ New features:: Bug fixes:: + * core: split startup command before evaluating it (issue #1643) * core: set server name when connecting to server with TLS (SNI extension) only if it's not an IPV4/IPv6 (issue #1635) * core: use function mallinfo2 instead of mallinfo when available (issue #1636) * core: display a warning when the file with certificate authorities is not found (option weechat.network.gnutls_ca_file) diff --git a/src/core/wee-command.c b/src/core/wee-command.c index cf942f510..cd8bc8494 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -8519,28 +8519,26 @@ command_init () void command_exec_list (const char *command_list) { - char *command_list2, **commands, **ptr_cmd; - struct t_gui_buffer *weechat_buffer; + char **commands, **ptr_command, *command_eval; if (!command_list || !command_list[0]) return; - command_list2 = eval_expression (command_list, NULL, NULL, NULL); - if (command_list2 && command_list2[0]) + commands = string_split_command (command_list, ';'); + if (commands) { - commands = string_split_command (command_list2, ';'); - if (commands) + for (ptr_command = commands; *ptr_command; ptr_command++) { - weechat_buffer = gui_buffer_search_main (); - for (ptr_cmd = commands; *ptr_cmd; ptr_cmd++) + command_eval = eval_expression (*ptr_command, NULL, NULL, NULL); + if (command_eval) { - (void) input_data (weechat_buffer, *ptr_cmd, NULL); + (void) input_data (gui_buffer_search_main (), + command_eval, NULL); + free (command_eval); } - string_free_split_command (commands); } + string_free_split_command (commands); } - if (command_list2) - free (command_list2); } /* diff --git a/src/core/wee-config.c b/src/core/wee-config.c index 33f5372eb..868ae1ee5 100644 --- a/src/core/wee-config.c +++ b/src/core/wee-config.c @@ -2552,15 +2552,17 @@ config_weechat_init_options () config_startup_command_after_plugins = config_file_new_option ( weechat_config_file, ptr_section, "command_after_plugins", "string", - N_("command executed when WeeChat starts, after loading plugins " - "(note: content is evaluated, see /help eval)"), + N_("command executed when WeeChat starts, after loading plugins; " + "multiple commands can be separated by semicolons " + "(note: commands are evaluated, see /help eval)"), NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); config_startup_command_before_plugins = config_file_new_option ( weechat_config_file, ptr_section, "command_before_plugins", "string", - N_("command executed when WeeChat starts, before loading plugins " - "(note: content is evaluated, see /help eval)"), + N_("command executed when WeeChat starts, before loading plugins; " + "multiple commands can be separated by semicolons " + "(note: commands are evaluated, see /help eval)"), NULL, 0, 0, "", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); config_startup_display_logo = config_file_new_option ( diff --git a/src/core/weechat.c b/src/core/weechat.c index 48364c9b8..cd83add1f 100644 --- a/src/core/weechat.c +++ b/src/core/weechat.c @@ -183,7 +183,7 @@ weechat_display_usage () " (see /help weechat.plugin.autoload)\n" " -r, --run-command run command(s) after startup;\n" " many commands can be separated by " - "semicolons,\n" + "semicolons and are evaluated,\n" " this option can be given multiple " "times\n" " -s, --no-script don't load any script at startup\n"