1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-02 07:46:38 +02:00

scripts: fix reset of "quiet" status in case of nested calls (issue #2046, issue #2126)

This commit is contained in:
Sébastien Helleu
2024-06-26 18:09:12 +02:00
parent dc283dd1c7
commit 3d3d8f2ea7
8 changed files with 110 additions and 43 deletions
+15 -7
View File
@@ -872,13 +872,15 @@ weechat_ruby_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input,
{
void *func_argv[1], *result;
char empty_arg[1] = { '\0' };
int old_ruby_quiet;
if (!ruby_script_eval)
{
old_ruby_quiet = ruby_quiet;
ruby_quiet = 1;
ruby_script_eval = weechat_ruby_load (WEECHAT_SCRIPT_EVAL_NAME,
RUBY_EVAL_SCRIPT);
ruby_quiet = 0;
ruby_quiet = old_ruby_quiet;
if (!ruby_script_eval)
return 0;
}
@@ -907,9 +909,10 @@ weechat_ruby_eval (struct t_gui_buffer *buffer, int send_to_buffer_as_input,
if (!weechat_config_boolean (ruby_config_look_eval_keep_context))
{
old_ruby_quiet = ruby_quiet;
ruby_quiet = 1;
weechat_ruby_unload (ruby_script_eval);
ruby_quiet = 0;
ruby_quiet = old_ruby_quiet;
ruby_script_eval = NULL;
}
@@ -926,7 +929,7 @@ weechat_ruby_command_cb (const void *pointer, void *data,
int argc, char **argv, char **argv_eol)
{
char *ptr_name, *ptr_code, *path_script;
int i, send_to_buffer_as_input, exec_commands;
int i, send_to_buffer_as_input, exec_commands, old_ruby_quiet;
/* make C compiler happy */
(void) pointer;
@@ -985,6 +988,7 @@ weechat_ruby_command_cb (const void *pointer, void *data,
|| (weechat_strcmp (argv[1], "reload") == 0)
|| (weechat_strcmp (argv[1], "unload") == 0))
{
old_ruby_quiet = ruby_quiet;
ptr_name = argv_eol[2];
if (strncmp (ptr_name, "-q ", 3) == 0)
{
@@ -1014,7 +1018,7 @@ weechat_ruby_command_cb (const void *pointer, void *data,
/* unload ruby script */
weechat_ruby_unload_name (ptr_name);
}
ruby_quiet = 0;
ruby_quiet = old_ruby_quiet;
}
else if (weechat_strcmp (argv[1], "eval") == 0)
{
@@ -1260,7 +1264,7 @@ weechat_ruby_signal_script_action_cb (const void *pointer, void *data,
int
weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
{
int ruby_error;
int ruby_error, old_ruby_quiet;
VALUE err;
char *weechat_ruby_code = {
"$stdout = WeechatOutputs\n"
@@ -1406,9 +1410,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
ruby_data.callback_load_file = &weechat_ruby_load_cb;
ruby_data.unload_all = &weechat_ruby_unload_all;
old_ruby_quiet = ruby_quiet;
ruby_quiet = 1;
plugin_script_init (weechat_ruby_plugin, &ruby_data);
ruby_quiet = 0;
ruby_quiet = old_ruby_quiet;
plugin_script_display_short_list (weechat_ruby_plugin,
ruby_scripts);
@@ -1424,7 +1429,10 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
int
weechat_plugin_end (struct t_weechat_plugin *plugin)
{
int old_ruby_quiet;
/* unload all scripts */
old_ruby_quiet = ruby_quiet;
ruby_quiet = 1;
if (ruby_script_eval)
{
@@ -1432,7 +1440,7 @@ weechat_plugin_end (struct t_weechat_plugin *plugin)
ruby_script_eval = NULL;
}
plugin_script_end (plugin, &ruby_data);
ruby_quiet = 0;
ruby_quiet = old_ruby_quiet;
ruby_cleanup (0);
signal (SIGCHLD, SIG_DFL);