trigger: add variables "${tg_shell_argc}" and "${tg_shell_argvN}" in command trigger evaluated strings (closes #1624)
This commit is contained in:
parent
3bf585ba04
commit
fae9bdf8f8
@ -24,6 +24,7 @@ New features::
|
||||
* core: quit WeeChat by default when signal SIGHUP is received in normal run, reload configuration in weechat-headless (issue #1595)
|
||||
* api: add support of pointer names in function string_eval_expression (direct and in hdata)
|
||||
* api: add info "weechat_daemon"
|
||||
* trigger: add variables "${tg_shell_argc}" and "${tg_shell_argvN}" in command trigger evaluated strings (issue #1624)
|
||||
|
||||
Bug fixes::
|
||||
|
||||
|
@ -4543,11 +4543,15 @@ Der Callback von "command" legt folgende Variablen in der Hashtable an:
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Typ | Beschreibung
|
||||
| buffer | pointer | Buffer.
|
||||
| tg_argc | string | Die Anzahl von Argumenten (der Befehl wird mitgezählt).
|
||||
| tg_argvN | string | Argument #N (`+tg_argv0+` ist der Befehl selber, die weiteren sind Argumente).
|
||||
| tg_argv_eolN | string | von Argument #N bis zum Ende der Argumente (`+tg_argv_eol0+` enthält den eigentlichen Befehl).
|
||||
| Variable | Typ | Beschreibung
|
||||
| buffer | pointer | Buffer.
|
||||
| tg_argc | string | Die Anzahl von Argumenten (der Befehl wird mitgezählt).
|
||||
| tg_argvN | string | Argument #N (`+tg_argv0+` ist der Befehl selber, die weiteren sind Argumente).
|
||||
| tg_argv_eolN | string | von Argument #N bis zum Ende der Argumente (`+tg_argv_eol0+` enthält den eigentlichen Befehl).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argc | string | The number of arguments with a split like the shell does (the command itself counts for one).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argvN | string | Argument #N with a split like the shell does (`+tg_shell_argv0+` is the command itself, the others are command arguments).
|
||||
|===
|
||||
|
||||
[[trigger_data_command_run]]
|
||||
|
@ -4453,11 +4453,13 @@ The "command" callback sets following variables in hashtable:
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| buffer | pointer | Buffer.
|
||||
| tg_argc | string | The number of arguments (the command itself counts for one).
|
||||
| tg_argvN | string | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
|
||||
| tg_argv_eolN | string | From argument #N until end of arguments (`+tg_argv_eol0+` includes the command itself).
|
||||
| Variable | Type | Description
|
||||
| buffer | pointer | Buffer.
|
||||
| tg_argc | string | The number of arguments (the command itself counts for one).
|
||||
| tg_argvN | string | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
|
||||
| tg_argv_eolN | string | From argument #N until end of arguments (`+tg_argv_eol0+` includes the command itself).
|
||||
| tg_shell_argc | string | The number of arguments with a split like the shell does (the command itself counts for one).
|
||||
| tg_shell_argvN | string | Argument #N with a split like the shell does (`+tg_shell_argv0+` is the command itself, the others are command arguments).
|
||||
|===
|
||||
|
||||
[[trigger_data_command_run]]
|
||||
|
@ -4605,11 +4605,13 @@ de hachage :
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| buffer | pointeur | Tampon.
|
||||
| tg_argc | chaîne | Nombre de paramètres (la commande elle-même compte pour un).
|
||||
| tg_argvN | chaîne | Paramètre n°N (`+tg_argv0+` est la commande elle-même, les autres sont les paramètres de la commande).
|
||||
| tg_argv_eolN | chaîne | Depuis le paramètre n°N jusqu'à la fin des paramètres (`+tg_argv_eol0+` inclut la commande elle-même).
|
||||
| Variable | Type | Description
|
||||
| buffer | pointeur | Tampon.
|
||||
| tg_argc | chaîne | Nombre de paramètres (la commande elle-même compte pour un).
|
||||
| tg_argvN | chaîne | Paramètre n°N (`+tg_argv0+` est la commande elle-même, les autres sont les paramètres de la commande).
|
||||
| tg_argv_eolN | chaîne | Depuis le paramètre n°N jusqu'à la fin des paramètres (`+tg_argv_eol0+` inclut la commande elle-même).
|
||||
| tg_shell_argc | chaîne | Nombre de paramètres avec un découpage comme le fait le shell (la commande elle-même compte pour un).
|
||||
| tg_shell_argvN | chaîne | Paramètre n°N avec un découpage comme le fait le shell (`+tg_shell_argv0+` est la commande elle-même, les autres sont les paramètres de la commande).
|
||||
|===
|
||||
|
||||
[[trigger_data_command_run]]
|
||||
|
@ -4773,11 +4773,15 @@ The "command" callback sets following variables in hashtable:
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Variable | Type | Description
|
||||
| buffer | pointer | Buffer.
|
||||
| tg_argc | string | The number of arguments (the command itself counts for one).
|
||||
| tg_argvN | string | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
|
||||
| tg_argv_eolN | string | From argument #N until end of arguments (`+tg_argv_eol0+` includes the command itself).
|
||||
| Variable | Type | Description
|
||||
| buffer | pointer | Buffer.
|
||||
| tg_argc | string | The number of arguments (the command itself counts for one).
|
||||
| tg_argvN | string | Argument #N (`+tg_argv0+` is the command itself, the others are command arguments).
|
||||
| tg_argv_eolN | string | From argument #N until end of arguments (`+tg_argv_eol0+` includes the command itself).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argc | string | The number of arguments with a split like the shell does (the command itself counts for one).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argvN | string | Argument #N with a split like the shell does (`+tg_shell_argv0+` is the command itself, the others are command arguments).
|
||||
|===
|
||||
|
||||
[[trigger_data_command_run]]
|
||||
|
@ -4521,14 +4521,18 @@ _weechat_print_ 修飾子では、メッセージタグを使う変数 (下の
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| 変数 | 型 | 説明
|
||||
| buffer | pointer | バッファ
|
||||
| 変数 | 型 | 説明
|
||||
| buffer | pointer | バッファ
|
||||
// TRANSLATION MISSING
|
||||
| tg_argc | string | The number of arguments (the command itself counts for one).
|
||||
| tg_argc | string | The number of arguments (the command itself counts for one).
|
||||
// TRANSLATION MISSING
|
||||
| tg_argvN | string | N 番目の引数 (`+tg_argv0+` is the command itself, the others are command arguments).
|
||||
| tg_argvN | string | N 番目の引数 (`+tg_argv0+` is the command itself, the others are command arguments).
|
||||
// TRANSLATION MISSING
|
||||
| tg_argv_eolN | string | N 番目の引数から最後の引数まで (`+tg_argv_eol0+` includes the command itself).
|
||||
| tg_argv_eolN | string | N 番目の引数から最後の引数まで (`+tg_argv_eol0+` includes the command itself).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argc | string | The number of arguments with a split like the shell does (the command itself counts for one).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argvN | string | Argument #N with a split like the shell does (`+tg_shell_argv0+` is the command itself, the others are command arguments).
|
||||
|===
|
||||
|
||||
[[trigger_data_command_run]]
|
||||
|
@ -4483,11 +4483,15 @@ Callback "command" ustawia następujące zmienne w tablicy hashy:
|
||||
|
||||
[width="100%",cols="3m,2,14",options="header"]
|
||||
|===
|
||||
| Zmienna | Typ | Opis
|
||||
| buffer | wskaźnik | Bufor.
|
||||
| tg_argc | ciąg | Ilość argumentów (komenda liczy się za jeden).
|
||||
| tg_argvN | ciąg | Argument #N (`+tg_argv0+` to komenda, pozostałe to jej argumenty).
|
||||
| tg_argv_eolN | ciąg | Od argumentu #N do końca argumentów (`+tg_argv_eol0+` zawiera komendę).
|
||||
| Zmienna | Typ | Opis
|
||||
| buffer | wskaźnik | Bufor.
|
||||
| tg_argc | ciąg | Ilość argumentów (komenda liczy się za jeden).
|
||||
| tg_argvN | ciąg | Argument #N (`+tg_argv0+` to komenda, pozostałe to jej argumenty).
|
||||
| tg_argv_eolN | ciąg | Od argumentu #N do końca argumentów (`+tg_argv_eol0+` zawiera komendę).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argc | ciąg | The number of arguments with a split like the shell does (the command itself counts for one).
|
||||
// TRANSLATION MISSING
|
||||
| tg_shell_argvN | ciąg | Argument #N with a split like the shell does (`+tg_shell_argv0+` is the command itself, the others are command arguments).
|
||||
|===
|
||||
|
||||
[[trigger_data_command_run]]
|
||||
|
@ -1042,8 +1042,8 @@ trigger_callback_command_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
int argc, char **argv, char **argv_eol)
|
||||
{
|
||||
char str_name[32], str_temp[128];
|
||||
int i;
|
||||
char str_name[64], str_value[128], **shell_argv;
|
||||
int i, shell_argc;
|
||||
|
||||
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
|
||||
|
||||
@ -1053,8 +1053,8 @@ trigger_callback_command_cb (const void *pointer, void *data,
|
||||
/* add data in hashtables used for conditions/replace/command */
|
||||
trigger_callback_set_common_vars (trigger, extra_vars);
|
||||
weechat_hashtable_set (pointers, "buffer", buffer);
|
||||
snprintf (str_temp, sizeof (str_temp), "%d", argc);
|
||||
weechat_hashtable_set (extra_vars, "tg_argc", str_temp);
|
||||
snprintf (str_value, sizeof (str_value), "%d", argc);
|
||||
weechat_hashtable_set (extra_vars, "tg_argc", str_value);
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
snprintf (str_name, sizeof (str_name), "tg_argv%d", i);
|
||||
@ -1062,6 +1062,22 @@ trigger_callback_command_cb (const void *pointer, void *data,
|
||||
snprintf (str_name, sizeof (str_name), "tg_argv_eol%d", i);
|
||||
weechat_hashtable_set (extra_vars, str_name, argv_eol[i]);
|
||||
}
|
||||
shell_argv = weechat_string_split_shell (argv_eol[0], &shell_argc);
|
||||
if (shell_argv)
|
||||
{
|
||||
snprintf (str_value, sizeof (str_value), "%d", shell_argc);
|
||||
weechat_hashtable_set (extra_vars, "tg_shell_argc", str_value);
|
||||
for (i = 0; i < shell_argc; i++)
|
||||
{
|
||||
snprintf (str_name, sizeof (str_name), "tg_shell_argv%d", i);
|
||||
weechat_hashtable_set (extra_vars, str_name, shell_argv[i]);
|
||||
}
|
||||
weechat_string_free_split (shell_argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_hashtable_set (extra_vars, "tg_shell_argc", "0");
|
||||
}
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
if (!trigger_callback_execute (trigger, buffer, pointers, extra_vars, NULL))
|
||||
|
Loading…
x
Reference in New Issue
Block a user