summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimmo Saan <simmo.saan@gmail.com>2015-11-18 21:19:10 +0200
committerSébastien Helleu <flashcode@flashtux.org>2020-05-17 09:46:10 +0200
commitb14cf0ac3d657fdc737ef9f0d47958190724e176 (patch)
treee145b7d89eb79ac74f3de52341ae7166a5f4c805 /src
parent8f6cc60a3fe27665a46dbd64d009ecf75b8cd746 (diff)
downloadweechat-b14cf0ac3d657fdc737ef9f0d47958190724e176.zip
trigger: only return trigger's return code when condition evaluates to true
Diffstat (limited to 'src')
-rw-r--r--src/plugins/trigger/trigger-callback.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/plugins/trigger/trigger-callback.c b/src/plugins/trigger/trigger-callback.c
index d5bfcf8ff..8c12e828c 100644
--- a/src/plugins/trigger/trigger-callback.c
+++ b/src/plugins/trigger/trigger-callback.c
@@ -393,9 +393,13 @@ trigger_callback_run_command (struct t_trigger *trigger,
* 2. check conditions (if false, exit)
* 3. replace text with regex
* 4. execute command(s)
+ *
+ * Returns:
+ * 1: conditions were true (or no condition set in trigger)
+ * 0: conditions were false
*/
-void
+int
trigger_callback_execute (struct t_trigger *trigger,
struct t_gui_buffer *buffer,
struct t_hashtable *pointers,
@@ -422,7 +426,11 @@ trigger_callback_execute (struct t_trigger *trigger,
/* execute command(s) */
trigger_callback_run_command (trigger, buffer, pointers, extra_vars,
display_monitor);
+
+ return 1;
}
+
+ return 0;
}
/*
@@ -529,7 +537,8 @@ trigger_callback_signal_cb (const void *pointer, void *data,
weechat_hashtable_set (extra_vars, "tg_signal_data", ptr_signal_data);
/* execute the trigger (conditions, regex, command) */
- trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
+ if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
+ trigger_rc = WEECHAT_RC_OK;
end:
TRIGGER_CALLBACK_CB_END(trigger_rc);
@@ -577,7 +586,8 @@ trigger_callback_hsignal_cb (const void *pointer, void *data,
weechat_hashtable_set (extra_vars, "tg_signal", signal);
/* execute the trigger (conditions, regex, command) */
- trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
+ if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
+ trigger_rc = WEECHAT_RC_OK;
end:
TRIGGER_CALLBACK_CB_END(trigger_rc);
@@ -989,7 +999,8 @@ trigger_callback_print_cb (const void *pointer, void *data,
goto end;
/* execute the trigger (conditions, regex, command) */
- trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
+ if (!trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL))
+ trigger_rc = WEECHAT_RC_OK;
end:
TRIGGER_CALLBACK_CB_END(trigger_rc);
@@ -1023,7 +1034,8 @@ trigger_callback_command_cb (const void *pointer, void *data,
}
/* execute the trigger (conditions, regex, command) */
- trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
+ if (!trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL))
+ trigger_rc = WEECHAT_RC_OK;
end:
TRIGGER_CALLBACK_CB_END(trigger_rc);
@@ -1048,7 +1060,8 @@ trigger_callback_command_run_cb (const void *pointer, void *data,
weechat_hashtable_set (extra_vars, "tg_command", command);
/* execute the trigger (conditions, regex, command) */
- trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL);
+ if (!trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL))
+ trigger_rc = WEECHAT_RC_OK;
end:
TRIGGER_CALLBACK_CB_END(trigger_rc);
@@ -1098,7 +1111,8 @@ trigger_callback_timer_cb (const void *pointer, void *data,
}
/* execute the trigger (conditions, regex, command) */
- trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
+ if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
+ trigger_rc = WEECHAT_RC_OK;
end:
TRIGGER_CALLBACK_CB_END(trigger_rc);
@@ -1121,7 +1135,8 @@ trigger_callback_config_cb (const void *pointer, void *data,
weechat_hashtable_set (extra_vars, "tg_value", value);
/* execute the trigger (conditions, regex, command) */
- trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL);
+ if (!trigger_callback_execute (trigger, NULL, pointers, extra_vars, NULL))
+ trigger_rc = WEECHAT_RC_OK;
end:
TRIGGER_CALLBACK_CB_END(trigger_rc);