From 916d99ad405d79853e323024d48a03176c587bca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sat, 17 Nov 2018 11:39:28 +0100 Subject: [PATCH] exec: add option exec.command.shell to customize the shell used with /exec -sh --- ChangeLog.adoc | 1 + doc/de/autogen/user/exec_options.adoc | 6 ++++++ doc/en/autogen/user/exec_options.adoc | 6 ++++++ doc/fr/autogen/user/exec_options.adoc | 6 ++++++ doc/it/autogen/user/exec_options.adoc | 6 ++++++ doc/ja/autogen/user/exec_options.adoc | 6 ++++++ doc/pl/autogen/user/exec_options.adoc | 6 ++++++ po/cs.po | 8 +++++++- po/de.po | 8 +++++++- po/es.po | 8 +++++++- po/fr.po | 13 +++++++++++-- po/hu.po | 8 +++++++- po/it.po | 8 +++++++- po/ja.po | 8 +++++++- po/pl.po | 8 +++++++- po/pt.po | 8 +++++++- po/pt_BR.po | 8 +++++++- po/ru.po | 8 +++++++- po/tr.po | 8 +++++++- po/weechat.pot | 8 +++++++- src/plugins/exec/exec-command.c | 23 +++++++++++++++++++---- src/plugins/exec/exec-config.c | 11 +++++++++++ src/plugins/exec/exec-config.h | 1 + 23 files changed, 163 insertions(+), 18 deletions(-) diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 2fa18c96b..bf1233847 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -24,6 +24,7 @@ New features:: * api: add functions string_base_encode and string_base_decode, remove functions string_encode_base64 and string_decode_base64 * api: add support of Time-based One-Time Password (TOTP), add infos "totp_generate" and "totp_validate" * buflist: add variable ${number2}, always set with the indented buffer number + * exec: add option exec.command.shell to customize the shell used with /exec -sh * relay: add support of close frame in websocket connection (issue #1281) * relay: add support of Time-based One-Time Password (TOTP) as second authentication factor in weechat protocol diff --git a/doc/de/autogen/user/exec_options.adoc b/doc/de/autogen/user/exec_options.adoc index 9cd96c348..c79d6e784 100644 --- a/doc/de/autogen/user/exec_options.adoc +++ b/doc/de/autogen/user/exec_options.adoc @@ -25,3 +25,9 @@ ** Typ: integer ** Werte: -1 .. 25920000 ** Standardwert: `+0+` + +* [[option_exec.command.shell]] *exec.command.shell* +** Beschreibung: pass:none[shell to use with command "/exec -sh"; it can be just the name of shell if it is in PATH (for example "bash") or the absolute path to the shell (for example "/bin/bash")] +** Typ: Zeichenkette +** Werte: beliebige Zeichenkette +** Standardwert: `+"sh"+` diff --git a/doc/en/autogen/user/exec_options.adoc b/doc/en/autogen/user/exec_options.adoc index 5d8555678..4ca387283 100644 --- a/doc/en/autogen/user/exec_options.adoc +++ b/doc/en/autogen/user/exec_options.adoc @@ -25,3 +25,9 @@ ** type: integer ** values: -1 .. 25920000 ** default value: `+0+` + +* [[option_exec.command.shell]] *exec.command.shell* +** description: pass:none[shell to use with command "/exec -sh"; it can be just the name of shell if it is in PATH (for example "bash") or the absolute path to the shell (for example "/bin/bash")] +** type: string +** values: any string +** default value: `+"sh"+` diff --git a/doc/fr/autogen/user/exec_options.adoc b/doc/fr/autogen/user/exec_options.adoc index d3cac1f23..185c7b073 100644 --- a/doc/fr/autogen/user/exec_options.adoc +++ b/doc/fr/autogen/user/exec_options.adoc @@ -25,3 +25,9 @@ ** type: entier ** valeurs: -1 .. 25920000 ** valeur par défaut: `+0+` + +* [[option_exec.command.shell]] *exec.command.shell* +** description: pass:none[shell à utiliser avec la commande "/exec -sh" ; cela peut être seulement le nom du shell s'il est dans le PATH (par exemple "bash") ou le chemin absolu vers le shell (par exemple "/bin/bash")] +** type: chaîne +** valeurs: toute chaîne +** valeur par défaut: `+"sh"+` diff --git a/doc/it/autogen/user/exec_options.adoc b/doc/it/autogen/user/exec_options.adoc index 7f8519ca9..e65192aae 100644 --- a/doc/it/autogen/user/exec_options.adoc +++ b/doc/it/autogen/user/exec_options.adoc @@ -25,3 +25,9 @@ ** tipo: intero ** valori: -1 .. 25920000 ** valore predefinito: `+0+` + +* [[option_exec.command.shell]] *exec.command.shell* +** descrizione: pass:none[shell to use with command "/exec -sh"; it can be just the name of shell if it is in PATH (for example "bash") or the absolute path to the shell (for example "/bin/bash")] +** tipo: stringa +** valori: qualsiasi stringa +** valore predefinito: `+"sh"+` diff --git a/doc/ja/autogen/user/exec_options.adoc b/doc/ja/autogen/user/exec_options.adoc index 28d1b16b9..077251563 100644 --- a/doc/ja/autogen/user/exec_options.adoc +++ b/doc/ja/autogen/user/exec_options.adoc @@ -25,3 +25,9 @@ ** タイプ: 整数 ** 値: -1 .. 25920000 ** デフォルト値: `+0+` + +* [[option_exec.command.shell]] *exec.command.shell* +** 説明: pass:none[shell to use with command "/exec -sh"; it can be just the name of shell if it is in PATH (for example "bash") or the absolute path to the shell (for example "/bin/bash")] +** タイプ: 文字列 +** 値: 未制約文字列 +** デフォルト値: `+"sh"+` diff --git a/doc/pl/autogen/user/exec_options.adoc b/doc/pl/autogen/user/exec_options.adoc index 69bc4bf1f..3248ca098 100644 --- a/doc/pl/autogen/user/exec_options.adoc +++ b/doc/pl/autogen/user/exec_options.adoc @@ -25,3 +25,9 @@ ** typ: liczba ** wartości: -1 .. 25920000 ** domyślna wartość: `+0+` + +* [[option_exec.command.shell]] *exec.command.shell* +** opis: pass:none[shell to use with command "/exec -sh"; it can be just the name of shell if it is in PATH (for example "bash") or the absolute path to the shell (for example "/bin/bash")] +** typ: ciąg +** wartości: dowolny ciąg +** domyślna wartość: `+"sh"+` diff --git a/po/cs.po b/po/cs.po index c57f8fda1..b426a6465 100644 --- a/po/cs.po +++ b/po/cs.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Ondřej Súkup \n" "Language-Team: weechat-dev \n" @@ -5472,6 +5472,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + #, fuzzy msgid "text color for a running command flag in list of commands" msgstr "barva textu pro akce ve vstupní řádce" diff --git a/po/de.po b/po/de.po index 4bf26c9c2..da7f65c67 100644 --- a/po/de.po +++ b/po/de.po @@ -24,7 +24,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 11:04+0100\n" "Last-Translator: Nils Görs \n" "Language-Team: German \n" @@ -6676,6 +6676,12 @@ msgstr "" "Wartezeit bis nicht mehr ausgeführte Befehle gelöscht werden (in Sekunden, 0 " "= lösche Befehle unmittelbar, -1 = niemals löschen)" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + msgid "text color for a running command flag in list of commands" msgstr "" "Textfarbe des Statusindikator (in der Auflistung der Befehle) für Befehle " diff --git a/po/es.po b/po/es.po index 5890992db..26e11fd34 100644 --- a/po/es.po +++ b/po/es.po @@ -22,7 +22,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Elián Hanisch \n" "Language-Team: weechat-dev \n" @@ -5687,6 +5687,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + #, fuzzy msgid "text color for a running command flag in list of commands" msgstr "color para acciones en la línea de entrada" diff --git a/po/fr.po b/po/fr.po index e03d151af..c7e539266 100644 --- a/po/fr.po +++ b/po/fr.po @@ -21,8 +21,8 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" -"PO-Revision-Date: 2018-11-17 10:35+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" +"PO-Revision-Date: 2018-11-17 11:37+0100\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" "Language: fr\n" @@ -6513,6 +6513,15 @@ msgstr "" "délai pour purger les commandes terminées (en secondes, 0 = purger les " "commandes immédiatement, -1 = ne jamais purger)" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" +"shell à utiliser avec la commande \"/exec -sh\" ; cela peut être seulement " +"le nom du shell s'il est dans le PATH (par exemple \"bash\") ou le chemin " +"absolu vers le shell (par exemple \"/bin/bash\")" + msgid "text color for a running command flag in list of commands" msgstr "" "couleur du texte pour le drapeau d'une commande qui tourne dans la liste des " diff --git a/po/hu.po b/po/hu.po index e5b5f9e5c..295ee0490 100644 --- a/po/hu.po +++ b/po/hu.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Andras Voroskoi \n" "Language-Team: weechat-dev \n" @@ -5001,6 +5001,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + #, fuzzy msgid "text color for a running command flag in list of commands" msgstr "kilépési nyíl színe" diff --git a/po/it.po b/po/it.po index e82a59180..3d011767c 100644 --- a/po/it.po +++ b/po/it.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Esteban I. Ruiz Moreno \n" "Language-Team: weechat-dev \n" @@ -5856,6 +5856,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + #, fuzzy msgid "text color for a running command flag in list of commands" msgstr "colore del testo per le azioni sulla riga di input" diff --git a/po/ja.po b/po/ja.po index 04ca3aeb7..f4bd37f72 100644 --- a/po/ja.po +++ b/po/ja.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: AYANOKOUZI, Ryuunosuke \n" "Language-Team: Japanese \n" "Language-Team: Polish \n" @@ -6357,6 +6357,12 @@ msgstr "" "opóźnienie dla kasowania zakończonych komend (w sekundach, 0 = natychmiast, " "-1 = nigdy)" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + msgid "text color for a running command flag in list of commands" msgstr "kolor dla flagi wykonywanej komendy na liście komend" diff --git a/po/pt.po b/po/pt.po index a768fa2db..6f625efa1 100644 --- a/po/pt.po +++ b/po/pt.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Vasco Almeida \n" "Language-Team: Portuguese <>\n" @@ -6209,6 +6209,12 @@ msgstr "" "atraso para purgar comandos concluídos (em segundos, 0 = eliminar comandos " "imediatamente, -1 = nunca eliminar)" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + msgid "text color for a running command flag in list of commands" msgstr "cor do texto do sinalizador de comando a executar na lista de comandos" diff --git a/po/pt_BR.po b/po/pt_BR.po index 465e57517..87d84b39f 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Eduardo Elias \n" "Language-Team: weechat-dev \n" @@ -5650,6 +5650,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + #, fuzzy msgid "text color for a running command flag in list of commands" msgstr "cor de texto para ações de linha de entrada" diff --git a/po/ru.po b/po/ru.po index 6777cfe8b..77fb52807 100644 --- a/po/ru.po +++ b/po/ru.po @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Aleksey V Zapparov AKA ixti \n" "Language-Team: weechat-dev \n" @@ -5039,6 +5039,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + #, fuzzy msgid "text color for a running command flag in list of commands" msgstr "цвет действий в поле ввода" diff --git a/po/tr.po b/po/tr.po index 1c39e1da9..4e5fcee1c 100644 --- a/po/tr.po +++ b/po/tr.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2018-11-17 10:36+0100\n" "Last-Translator: Hasan Kiran \n" "Language-Team: weechat-dev \n" @@ -4592,6 +4592,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + #, fuzzy msgid "text color for a running command flag in list of commands" msgstr "kanal isimleri için metin rengi" diff --git a/po/weechat.pot b/po/weechat.pot index be4242aa9..e14689291 100644 --- a/po/weechat.pot +++ b/po/weechat.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: WeeChat\n" "Report-Msgid-Bugs-To: flashcode@flashtux.org\n" -"POT-Creation-Date: 2018-11-17 08:09+0100\n" +"POT-Creation-Date: 2018-11-17 11:35+0100\n" "PO-Revision-Date: 2014-08-16 10:27+0200\n" "Last-Translator: Sébastien Helleu \n" "Language-Team: weechat-dev \n" @@ -4573,6 +4573,12 @@ msgid "" "immediately, -1 = never purge)" msgstr "" +msgid "" +"shell to use with command \"/exec -sh\"; it can be just the name of shell if " +"it is in PATH (for example \"bash\") or the absolute path to the shell (for " +"example \"/bin/bash\")" +msgstr "" + msgid "text color for a running command flag in list of commands" msgstr "" diff --git a/src/plugins/exec/exec-command.c b/src/plugins/exec/exec-command.c index b5e4dfc52..32a00c410 100644 --- a/src/plugins/exec/exec-command.c +++ b/src/plugins/exec/exec-command.c @@ -405,7 +405,8 @@ int exec_command_run (struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol, int start_arg) { - char str_buffer[512]; + char str_buffer[512], *default_shell = "sh"; + const char *ptr_shell; struct t_exec_cmd *new_exec_cmd; struct t_exec_cmd_options cmd_options; struct t_hashtable *process_options; @@ -480,6 +481,19 @@ exec_command_run (struct t_gui_buffer *buffer, /* automatically disable shell if we are downloading an URL */ if (strncmp (argv_eol[cmd_options.command_index], "url:", 4) == 0) cmd_options.use_shell = 0; + + /* get default shell */ + if (cmd_options.use_shell) + { + ptr_shell = weechat_config_string (exec_config_command_shell); + if (!ptr_shell || !ptr_shell[0]) + ptr_shell = default_shell; + } + else + { + ptr_shell = NULL; + } + if (cmd_options.use_shell) { /* command will be: sh -c "command arguments..." */ @@ -574,14 +588,15 @@ exec_command_run (struct t_gui_buffer *buffer, /* execute the command */ if (weechat_exec_plugin->debug >= 1) { - weechat_printf (NULL, "%s: executing command: \"%s%s%s\"", + weechat_printf (NULL, "%s: executing command: \"%s%s%s%s\"", EXEC_PLUGIN_NAME, - (cmd_options.use_shell) ? "sh -c '" : "", + (cmd_options.use_shell) ? ptr_shell : "", + (cmd_options.use_shell) ? " -c '" : "", argv_eol[cmd_options.command_index], (cmd_options.use_shell) ? "'" : ""); } new_exec_cmd->hook = weechat_hook_process_hashtable ( - (cmd_options.use_shell) ? "sh" : argv_eol[cmd_options.command_index], + (cmd_options.use_shell) ? ptr_shell : argv_eol[cmd_options.command_index], process_options, cmd_options.timeout * 1000, &exec_process_cb, diff --git a/src/plugins/exec/exec-config.c b/src/plugins/exec/exec-config.c index 43693aa47..017cff635 100644 --- a/src/plugins/exec/exec-config.c +++ b/src/plugins/exec/exec-config.c @@ -34,6 +34,7 @@ struct t_config_file *exec_config_file = NULL; struct t_config_option *exec_config_command_default_options; struct t_config_option *exec_config_command_purge_delay; +struct t_config_option *exec_config_command_shell; /* exec config, color section */ @@ -130,6 +131,16 @@ exec_config_init () "commands immediately, -1 = never purge)"), NULL, -1, 36000 * 24 * 30, "0", NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + exec_config_command_shell = weechat_config_new_option ( + exec_config_file, ptr_section, + "shell", "string", + N_("shell to use with command \"/exec -sh\"; it can be just the name " + "of shell if it is in PATH (for example \"bash\") or the absolute " + "path to the shell (for example \"/bin/bash\")"), + NULL, 0, 0, "sh", NULL, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); /* color */ ptr_section = weechat_config_new_section (exec_config_file, "color", diff --git a/src/plugins/exec/exec-config.h b/src/plugins/exec/exec-config.h index 537597c11..ded5fde01 100644 --- a/src/plugins/exec/exec-config.h +++ b/src/plugins/exec/exec-config.h @@ -26,6 +26,7 @@ extern struct t_config_file *exec_config_file; extern struct t_config_option *exec_config_command_default_options; extern struct t_config_option *exec_config_command_purge_delay; +extern struct t_config_option *exec_config_command_shell; extern struct t_config_option *exec_config_color_flag_running; extern struct t_config_option *exec_config_color_flag_finished;