mirror of
https://github.com/weechat/weechat.git
synced 2026-07-01 07:16:37 +02:00
exec: add option exec.command.shell to customize the shell used with /exec -sh
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user