1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core: add option -e to evaluate all commands before executing them in command /eval

This commit is contained in:
Sébastien Helleu
2026-03-14 00:03:27 +01:00
parent 27ae6ca789
commit 9bf2d51493
16 changed files with 256 additions and 138 deletions
+4
View File
@@ -8,6 +8,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
## Version 4.9.0 (under dev)
### Changed
- core: add option `-e` to evaluate all commands before executing them in command `/eval`
### Added
- typing: add option typing.look.item_text ([#2305](https://github.com/weechat/weechat/issues/2305))
+5 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:24+0100\n"
"Last-Translator: Ondřej Súkup <mimi.vx@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1761,7 +1761,7 @@ msgstr "vyhodnotit výraz"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <výraz> || [-n] -c <výraz1> <operátor> <výraz2>"
@@ -1773,6 +1773,9 @@ msgid ""
"separated by semicolons)"
msgstr ""
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+9 -2
View File
@@ -28,7 +28,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:38+0100\n"
"Last-Translator: Nils Görs <weechatter@arcor.de>\n"
"Language-Team: German <kde-i18n-de@kde.org>\n"
@@ -1841,8 +1841,12 @@ msgid "evaluate expression"
msgstr "evaluierter Ausdruck"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
#| msgid ""
#| "[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
#| "<expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
@@ -1860,6 +1864,9 @@ msgstr ""
"raw[-s]: teilt Ausdrücke, bevor sie evaluiert werden (mehrere Befehle können "
"durch Semikolon getrennt werden)"
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+9 -2
View File
@@ -24,7 +24,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:24+0100\n"
"Last-Translator: Santiago Forero <santiago@forero.xyz>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1823,8 +1823,12 @@ msgid "evaluate expression"
msgstr "evaluar expresión"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
#| msgid ""
#| "[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
#| "<expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
"[-n|-s] [-d] <expresión> || [-n] [-d [-d]] -c <expresión1> <operador> "
@@ -1838,6 +1842,9 @@ msgid ""
"separated by semicolons)"
msgstr ""
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+8 -5
View File
@@ -23,8 +23,8 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"PO-Revision-Date: 2026-03-12 20:30+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-13 23:38+0100\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
"Language: fr\n"
@@ -1822,11 +1822,11 @@ msgstr "évaluer une expression"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
"[-n|-s] [-d [-d]] <expression> || [-n] [-d] -c <expression1> <opérateur> "
"<expression2>"
"[-n|-s] [-e] [-d [-d]] <expression> || [-n] [-d] -c <expression1> "
"<opérateur> <expression2>"
msgid "raw[-n]: display result without sending it to buffer (debug mode)"
msgstr "raw[-n] : afficher le résultat sans envoyer au tampon (mode debug)"
@@ -1838,6 +1838,9 @@ msgstr ""
"raw[-s] : découper l'expression avant de l'évaluer (plusieurs commandes "
"peuvent être séparées par des points-virgules)"
msgid "raw[-e]: evaluate all commands before executing them"
msgstr "raw[-e]: évaluer toutes les commandes avant de les exécuter"
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+5 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-08 08:59+0100\n"
"Last-Translator: Andras Voroskoi <voroskoi@frugalware.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1702,7 +1702,7 @@ msgstr ""
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
@@ -1714,6 +1714,9 @@ msgid ""
"separated by semicolons)"
msgstr ""
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+5 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:24+0100\n"
"Last-Translator: Esteban I. Ruiz Moreno <exio4.com@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1762,7 +1762,7 @@ msgstr ""
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
"[-n] <espressione> || [-n] -c <espressione1> <operatore> <espressione2>"
@@ -1775,6 +1775,9 @@ msgid ""
"separated by semicolons)"
msgstr ""
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+5 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:24+0100\n"
"Last-Translator: AYANOKOUZI, Ryuunosuke <i38w7i3@yahoo.co.jp>\n"
"Language-Team: Japanese <https://github.com/l/weechat/tree/master/"
@@ -1803,7 +1803,7 @@ msgstr "式を評価"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
@@ -1821,6 +1821,9 @@ msgstr ""
"正規表現置換が行われた後に条件が満足された場合に実行するコマンド (多くのコマ"
"ンドを実行するにはセミコロンで区切ってください)"
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+9 -2
View File
@@ -24,7 +24,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:25+0100\n"
"Last-Translator: Krzysztof Korościk <soltys@soltys.info>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1789,8 +1789,12 @@ msgid "evaluate expression"
msgstr "przetwórz wyrażenie"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
#| msgid ""
#| "[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
#| "<expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
"[-n|-s] [-d] <wyrażenie> || [-n] [-d [-d]] -c <wyrażenie1> <operator> "
@@ -1806,6 +1810,9 @@ msgstr ""
"raw[-s]: podziel wyrażenie przed ewaluacją (wiele komend można oddzielić "
"średnikami)"
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+5 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:24+0100\n"
"Last-Translator: Vasco Almeida <vascomalmeida@sapo.pt>\n"
"Language-Team: Portuguese <>\n"
@@ -1811,7 +1811,7 @@ msgstr "avaliar uma expressão"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <expressão> || [-n] -c <expressão1> <operador> <expressão2>"
@@ -1829,6 +1829,9 @@ msgstr ""
"comandos a executar se as condições estiverem bem, depois de substituir as "
"expressões regulares (pode separar vários comandos por ponto e vírgula)"
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+5 -2
View File
@@ -46,7 +46,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:19+0100\n"
"Last-Translator: Érico Nogueira <ericonr@disroot.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1795,7 +1795,7 @@ msgstr "avaliar expressão"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] <expression> || [-n] -c <expression1> <operator> <expression2>"
@@ -1807,6 +1807,9 @@ msgid ""
"separated by semicolons)"
msgstr ""
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+5 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-08 08:59+0100\n"
"Last-Translator: Aleksey V Zapparov AKA ixti <ixti@member.fsf.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1724,7 +1724,7 @@ msgstr ""
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
@@ -1736,6 +1736,9 @@ msgid ""
"separated by semicolons)"
msgstr ""
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+9 -2
View File
@@ -22,7 +22,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:26+0100\n"
"Last-Translator: Ivan Pešić <ivan.pesic@gmail.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1775,8 +1775,12 @@ msgid "evaluate expression"
msgstr "израчунавање израза"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
#| msgid ""
#| "[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
#| "<expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] [-d] <израз> || [-n] [-d [-d]] -c <израз1> <оператор> <израз2>"
@@ -1790,6 +1794,9 @@ msgstr ""
"raw[-s]: дели израз пре израчунавања (многе команде могу да се раздвоје са "
"тачка запетама)"
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+9 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2026-03-12 20:24+0100\n"
"Last-Translator: Emir SARI <emir_sari@icloud.com>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1781,8 +1781,12 @@ msgid "evaluate expression"
msgstr "ifadeyi değerlendir"
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
#, fuzzy
#| msgid ""
#| "[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
#| "<expression2>"
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr "[-n|-s] [-d] <ifade> || [-n] [-d] -c <ifade1> <işleç> <ifade2>"
@@ -1796,6 +1800,9 @@ msgstr ""
"raw[-s]: İfadeyi değerlendirmeden önce böl (birden çok komut noktalı "
"virgülle ayrılabilir)"
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+5 -2
View File
@@ -23,7 +23,7 @@ msgid ""
msgstr ""
"Project-Id-Version: WeeChat\n"
"Report-Msgid-Bugs-To: flashcode@flashtux.org\n"
"POT-Creation-Date: 2026-03-12 20:25+0100\n"
"POT-Creation-Date: 2026-03-13 23:38+0100\n"
"PO-Revision-Date: 2014-08-16 10:27+0200\n"
"Last-Translator: Sébastien Helleu <flashcode@flashtux.org>\n"
"Language-Team: weechat-dev <weechat-dev@nongnu.org>\n"
@@ -1599,7 +1599,7 @@ msgstr ""
#. TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated
msgid ""
"[-n|-s] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"[-n|-s] [-e] [-d] <expression> || [-n] [-d [-d]] -c <expression1> <operator> "
"<expression2>"
msgstr ""
@@ -1611,6 +1611,9 @@ msgid ""
"separated by semicolons)"
msgstr ""
msgid "raw[-e]: evaluate all commands before executing them"
msgstr ""
msgid ""
"raw[-d]: display debug output after evaluation (with two -d: more verbose "
"debug)"
+159 -107
View File
@@ -2348,10 +2348,12 @@ command_eval_print_debug (const char *debug)
COMMAND_CALLBACK(eval)
{
int i, rc, print_only, split_command, condition, debug, error;
int i, rc, print_only, split_command, eval_first, condition, debug, error;
char *result, *ptr_args, **commands, **ptr_command, str_debug[32];
const char *debug_output;
struct t_hashtable *pointers, *options;
struct t_weelist *list_commands;
struct t_weelist_item *ptr_item;
/* make C compiler happy */
(void) pointer;
@@ -2361,6 +2363,7 @@ COMMAND_CALLBACK(eval)
rc = WEECHAT_RC_OK;
print_only = 0;
split_command = 0;
eval_first = 0;
condition = 0;
debug = 0;
error = 0;
@@ -2380,6 +2383,11 @@ COMMAND_CALLBACK(eval)
split_command = 1;
ptr_args = argv_eol[i + 1];
}
else if (string_strcmp (argv[i], "-e") == 0)
{
eval_first = 1;
ptr_args = argv_eol[i + 1];
}
else if (string_strcmp (argv[i], "-c") == 0)
{
condition = 1;
@@ -2397,97 +2405,89 @@ COMMAND_CALLBACK(eval)
}
}
if (ptr_args)
if (!ptr_args)
return rc;
pointers = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
NULL,
NULL);
if (pointers)
{
pointers = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_POINTER,
NULL,
NULL);
if (pointers)
{
hashtable_set (pointers, "window",
gui_window_search_with_buffer (buffer));
hashtable_set (pointers, "buffer", buffer);
}
hashtable_set (pointers, "window",
gui_window_search_with_buffer (buffer));
hashtable_set (pointers, "buffer", buffer);
}
options = NULL;
if (condition || debug)
options = NULL;
if (condition || debug)
{
options = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (options)
{
options = hashtable_new (32,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL,
NULL);
if (options)
if (condition)
hashtable_set (options, "type", "condition");
if (debug > 0)
{
if (condition)
hashtable_set (options, "type", "condition");
if (debug > 0)
{
snprintf (str_debug, sizeof (str_debug), "%d", debug);
hashtable_set (options, "debug", str_debug);
}
snprintf (str_debug, sizeof (str_debug), "%d", debug);
hashtable_set (options, "debug", str_debug);
}
}
}
if (print_only)
if (print_only)
{
result = eval_expression (ptr_args, pointers, NULL, options);
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t>> %s", ptr_args);
if (result)
{
result = eval_expression (ptr_args, pointers, NULL, options);
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t>> %s", ptr_args);
if (result)
{
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s[%s%s%s]",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
result,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
free (result);
}
else
{
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s<%s%s%s>",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
_("error"),
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
}
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
command_eval_print_debug (debug_output);
}
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s[%s%s%s]",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
result,
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
free (result);
}
else
{
if (split_command)
gui_chat_printf_date_tags (NULL, 0, "no_log", "\t== %s<%s%s%s>",
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS),
GUI_COLOR(GUI_COLOR_CHAT),
_("error"),
GUI_COLOR(GUI_COLOR_CHAT_DELIMITERS));
}
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
command_eval_print_debug (debug_output);
}
return rc;
}
if (split_command)
{
commands = string_split_command (ptr_args, ';');
if (commands)
{
if (eval_first)
{
commands = string_split_command (ptr_args, ';');
if (commands)
list_commands = weelist_new ();
if (list_commands)
{
/* first build a list of all evaluated commands */
for (ptr_command = commands; *ptr_command; ptr_command++)
{
if (!gui_buffer_valid (buffer))
{
buffer = gui_current_window->buffer;
if (pointers)
{
hashtable_set (pointers, "window",
gui_window_search_with_buffer (buffer));
hashtable_set (pointers, "buffer", buffer);
}
}
result = eval_expression (*ptr_command, pointers, NULL,
options);
result = eval_expression (*ptr_command, pointers, NULL, options);
if (result)
{
(void) input_data (buffer,
result,
NULL,
0, /* split_newline */
0); /* user_data */
weelist_add (list_commands, result, WEECHAT_LIST_POS_END, NULL);
free (result);
}
else
@@ -2502,46 +2502,97 @@ COMMAND_CALLBACK(eval)
command_eval_print_debug (debug_output);
}
}
string_free_split_command (commands);
/* execute evaluated commands */
for (ptr_item = list_commands->items; ptr_item;
ptr_item = ptr_item->next_item)
{
if (!gui_buffer_valid (buffer))
buffer = gui_current_window->buffer;
(void) input_data (buffer,
ptr_item->data,
NULL,
0, /* split_newline */
0); /* user_data */
}
weelist_free (list_commands);
}
}
else
{
result = eval_expression (ptr_args, pointers, NULL, options);
if (result)
for (ptr_command = commands; *ptr_command; ptr_command++)
{
(void) input_data (buffer,
result,
NULL,
0, /* split_newline */
0); /* user_data */
free (result);
}
else
{
error = 1;
}
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
command_eval_print_debug (debug_output);
if (!gui_buffer_valid (buffer))
{
buffer = gui_current_window->buffer;
if (pointers)
{
hashtable_set (pointers, "window",
gui_window_search_with_buffer (buffer));
hashtable_set (pointers, "buffer", buffer);
}
}
result = eval_expression (*ptr_command, pointers, NULL,
options);
if (result)
{
(void) input_data (buffer,
result,
NULL,
0, /* split_newline */
0); /* user_data */
free (result);
}
else
{
error = 1;
}
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
command_eval_print_debug (debug_output);
}
}
}
string_free_split_command (commands);
}
if (error)
{
gui_chat_printf (NULL,
_("%sError in expression to evaluate"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
rc = WEECHAT_RC_ERROR;
}
hashtable_free (pointers);
hashtable_free (options);
}
else
{
result = eval_expression (ptr_args, pointers, NULL, options);
if (result)
{
(void) input_data (buffer,
result,
NULL,
0, /* split_newline */
0); /* user_data */
free (result);
}
else
{
error = 1;
}
if (options && debug)
{
debug_output = hashtable_get (options,
"debug_output");
if (debug_output)
command_eval_print_debug (debug_output);
}
}
if (error)
{
gui_chat_printf (NULL,
_("%sError in expression to evaluate"),
gui_chat_prefix[GUI_CHAT_PREFIX_ERROR]);
rc = WEECHAT_RC_ERROR;
}
hashtable_free (pointers);
hashtable_free (options);
return rc;
}
@@ -8756,12 +8807,13 @@ command_init (void)
NULL, "eval",
N_("evaluate expression"),
/* TRANSLATORS: only text between angle brackets (eg: "<name>") may be translated */
N_("[-n|-s] [-d] <expression>"
N_("[-n|-s] [-e] [-d] <expression>"
" || [-n] [-d [-d]] -c <expression1> <operator> <expression2>"),
CMD_ARGS_DESC(
N_("raw[-n]: display result without sending it to buffer (debug mode)"),
N_("raw[-s]: split expression before evaluating it "
"(many commands can be separated by semicolons)"),
N_("raw[-e]: evaluate all commands before executing them"),
N_("raw[-d]: display debug output after evaluation "
"(with two -d: more verbose debug)"),
N_("raw[-c]: evaluate as condition: use operators and parentheses, "