summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-05-22 08:29:23 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-05-22 08:52:46 +0200
commitd949ebb08828ccdb3f78a1f42f7c1c791ca08b7d (patch)
tree7d9bbff982a89a1699d43206316fd0e292d3f021 /src/core
parentb74af1d2daa3bb597164d292021f367716b9e0b7 (diff)
downloadweechat-d949ebb08828ccdb3f78a1f42f7c1c791ca08b7d.zip
core: split signal command before evaluating it (issue #1643)
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-config.c10
-rw-r--r--src/core/wee-signal.c33
2 files changed, 20 insertions, 23 deletions
diff --git a/src/core/wee-config.c b/src/core/wee-config.c
index 868ae1ee5..c02f45e7e 100644
--- a/src/core/wee-config.c
+++ b/src/core/wee-config.c
@@ -4611,7 +4611,7 @@ config_weechat_init_options ()
"sighup", "string",
N_("command to execute when the signal is received, "
"multiple commands can be separated by semicolons "
- "(note: content is evaluated, see /help eval)"),
+ "(note: commands are evaluated, see /help eval)"),
NULL, 0, 0,
"${if:${info:weechat_headless}?/reload:/quit -yes}", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
@@ -4620,7 +4620,7 @@ config_weechat_init_options ()
"sigquit", "string",
N_("command to execute when the signal is received, "
"multiple commands can be separated by semicolons "
- "(note: content is evaluated, see /help eval)"),
+ "(note: commands are evaluated, see /help eval)"),
NULL, 0, 0, "/quit -yes", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_signal_sigterm = config_file_new_option (
@@ -4628,7 +4628,7 @@ config_weechat_init_options ()
"sigterm", "string",
N_("command to execute when the signal is received, "
"multiple commands can be separated by semicolons "
- "(note: content is evaluated, see /help eval)"),
+ "(note: commands are evaluated, see /help eval)"),
NULL, 0, 0, "/quit -yes", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_signal_sigusr1 = config_file_new_option (
@@ -4636,7 +4636,7 @@ config_weechat_init_options ()
"sigusr1", "string",
N_("command to execute when the signal is received, "
"multiple commands can be separated by semicolons "
- "(note: content is evaluated, see /help eval)"),
+ "(note: commands are evaluated, see /help eval)"),
NULL, 0, 0, "", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
config_signal_sigusr2 = config_file_new_option (
@@ -4644,7 +4644,7 @@ config_weechat_init_options ()
"sigusr2", "string",
N_("command to execute when the signal is received, "
"multiple commands can be separated by semicolons "
- "(note: content is evaluated, see /help eval)"),
+ "(note: commands are evaluated, see /help eval)"),
NULL, 0, 0, "", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
diff --git a/src/core/wee-signal.c b/src/core/wee-signal.c
index c53fc5e31..5e394b486 100644
--- a/src/core/wee-signal.c
+++ b/src/core/wee-signal.c
@@ -202,35 +202,32 @@ signal_send_to_weechat (int signal_index)
void
signal_exec_command (int signal_index, const char *command)
{
- char *command_eval, **commands, **ptr_cmd, str_signal[32];
- struct t_gui_buffer *weechat_buffer;
+ char str_signal[32], **commands, **ptr_command, *command_eval;
if (!command || !command[0])
return;
- command_eval = eval_expression (command, NULL, NULL, NULL);
- if (!command_eval)
- return;
+ snprintf (str_signal, sizeof (str_signal),
+ "sig%s", signal_list[signal_index].name);
+ string_toupper (str_signal);
- if (command_eval[0])
+ commands = string_split_command (command, ';');
+ if (commands)
{
- snprintf (str_signal, sizeof (str_signal),
- "sig%s", signal_list[signal_index].name);
- string_toupper (str_signal);
- log_printf ("Signal %s received, executing command: %s",
- str_signal, command_eval);
- commands = string_split_command (command_eval, ';');
- 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);
+ log_printf ("Signal %s received, executing command: \"%s\"",
+ str_signal, command_eval);
+ (void) input_data (gui_buffer_search_main (),
+ command_eval, NULL);
+ free (command_eval);
}
- string_free_split_command (commands);
}
+ string_free_split_command (commands);
}
- free (command_eval);
}
/*