diff --git a/CHANGELOG.md b/CHANGELOG.md index fc59b77dd..96b35668e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/po/cs.po b/po/cs.po index 165f26a07..2dc575a65 100644 --- a/po/cs.po +++ b/po/cs.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1761,7 +1761,7 @@ msgstr "vyhodnotit výraz" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated #, fuzzy msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "[-n|-s] || [-n] -c " @@ -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)" diff --git a/po/de.po b/po/de.po index 714c5abeb..904e7ec48 100644 --- a/po/de.po +++ b/po/de.po @@ -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 \n" "Language-Team: German \n" @@ -1841,8 +1841,12 @@ msgid "evaluate expression" msgstr "evaluierter Ausdruck" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated +#, fuzzy +#| msgid "" +#| "[-n|-s] [-d] || [-n] [-d [-d]] -c " +#| "" msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "" "[-n|-s] [-d] || [-n] [-d [-d]] -c " @@ -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)" diff --git a/po/es.po b/po/es.po index dfa9a68a4..4cb95777f 100644 --- a/po/es.po +++ b/po/es.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1823,8 +1823,12 @@ msgid "evaluate expression" msgstr "evaluar expresión" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated +#, fuzzy +#| msgid "" +#| "[-n|-s] [-d] || [-n] [-d [-d]] -c " +#| "" msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "" "[-n|-s] [-d] || [-n] [-d [-d]] -c " @@ -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)" diff --git a/po/fr.po b/po/fr.po index 55caf5e03..e2301a9d6 100644 --- a/po/fr.po +++ b/po/fr.po @@ -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 \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -1822,11 +1822,11 @@ msgstr "évaluer une expression" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "" -"[-n|-s] [-d [-d]] || [-n] [-d] -c " -"" +"[-n|-s] [-e] [-d [-d]] || [-n] [-d] -c " +" " 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)" diff --git a/po/hu.po b/po/hu.po index 9cd353302..0f1e8c5de 100644 --- a/po/hu.po +++ b/po/hu.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1702,7 +1702,7 @@ msgstr "" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" 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)" diff --git a/po/it.po b/po/it.po index d6adbeee7..4602d168f 100644 --- a/po/it.po +++ b/po/it.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1762,7 +1762,7 @@ msgstr "" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated #, fuzzy msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "" "[-n] || [-n] -c " @@ -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)" diff --git a/po/ja.po b/po/ja.po index b0ff449c6..b4a02c3a8 100644 --- a/po/ja.po +++ b/po/ja.po @@ -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 \n" "Language-Team: Japanese ") may be translated #, fuzzy msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "[-n|-s] || [-n] -c " @@ -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)" diff --git a/po/pl.po b/po/pl.po index e7950e47a..83719cda4 100644 --- a/po/pl.po +++ b/po/pl.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1789,8 +1789,12 @@ msgid "evaluate expression" msgstr "przetwórz wyrażenie" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated +#, fuzzy +#| msgid "" +#| "[-n|-s] [-d] || [-n] [-d [-d]] -c " +#| "" msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "" "[-n|-s] [-d] || [-n] [-d [-d]] -c " @@ -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)" diff --git a/po/pt.po b/po/pt.po index 026ecdbd0..e6f1e8f16 100644 --- a/po/pt.po +++ b/po/pt.po @@ -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 \n" "Language-Team: Portuguese <>\n" @@ -1811,7 +1811,7 @@ msgstr "avaliar uma expressão" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated #, fuzzy msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "[-n|-s] || [-n] -c " @@ -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)" diff --git a/po/pt_BR.po b/po/pt_BR.po index 8ba4d8583..371282586 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1795,7 +1795,7 @@ msgstr "avaliar expressão" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated #, fuzzy msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "[-n|-s] || [-n] -c " @@ -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)" diff --git a/po/ru.po b/po/ru.po index 346c4198d..7ce25f3c0 100644 --- a/po/ru.po +++ b/po/ru.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1724,7 +1724,7 @@ msgstr "" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" 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)" diff --git a/po/sr.po b/po/sr.po index 5c2b57eba..6e0a4ec94 100644 --- a/po/sr.po +++ b/po/sr.po @@ -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ć \n" "Language-Team: weechat-dev \n" @@ -1775,8 +1775,12 @@ msgid "evaluate expression" msgstr "израчунавање израза" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated +#, fuzzy +#| msgid "" +#| "[-n|-s] [-d] || [-n] [-d [-d]] -c " +#| "" msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" 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)" diff --git a/po/tr.po b/po/tr.po index 9b61197a5..8a73b839e 100644 --- a/po/tr.po +++ b/po/tr.po @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1781,8 +1781,12 @@ msgid "evaluate expression" msgstr "ifadeyi değerlendir" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated +#, fuzzy +#| msgid "" +#| "[-n|-s] [-d] || [-n] [-d [-d]] -c " +#| "" msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" msgstr "[-n|-s] [-d] || [-n] [-d] -c " @@ -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)" diff --git a/po/weechat.pot b/po/weechat.pot index 901dd6d84..f7ce72b40 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -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 \n" "Language-Team: weechat-dev \n" @@ -1599,7 +1599,7 @@ msgstr "" #. TRANSLATORS: only text between angle brackets (eg: "") may be translated msgid "" -"[-n|-s] [-d] || [-n] [-d [-d]] -c " +"[-n|-s] [-e] [-d] || [-n] [-d [-d]] -c " "" 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)" diff --git a/src/core/core-command.c b/src/core/core-command.c index be92b7865..cc83f1936 100644 --- a/src/core/core-command.c +++ b/src/core/core-command.c @@ -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: "") may be translated */ - N_("[-n|-s] [-d] " + N_("[-n|-s] [-e] [-d] " " || [-n] [-d [-d]] -c "), 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, "