diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2020-10-11 16:33:50 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2020-10-11 16:33:50 +0200 |
commit | fa46a2fe2d1d785c76f1584ac838bf767bf0e56c (patch) | |
tree | 0f3f076b994e2a31b1f53ad72b9c7331ed94110f /src | |
parent | 4d696d7cc86d04277fba288228dd376c542c5e18 (diff) | |
download | weechat-fa46a2fe2d1d785c76f1584ac838bf767bf0e56c.zip |
exec: add option "-oerr" to send stderr to buffer (now disabled by default) (closes #1566)
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/exec/exec-command.c | 10 | ||||
-rw-r--r-- | src/plugins/exec/exec-command.h | 1 | ||||
-rw-r--r-- | src/plugins/exec/exec.c | 9 | ||||
-rw-r--r-- | src/plugins/exec/exec.h | 1 |
4 files changed, 20 insertions, 1 deletions
diff --git a/src/plugins/exec/exec-command.c b/src/plugins/exec/exec-command.c index 0f329ed03..e917ee70b 100644 --- a/src/plugins/exec/exec-command.c +++ b/src/plugins/exec/exec-command.c @@ -244,6 +244,10 @@ exec_command_parse_options (struct t_exec_cmd_options *cmd_options, cmd_options->output_to_buffer_exec_cmd = 1; cmd_options->new_buffer = 0; } + else if (weechat_strcasecmp (argv[i], "-oerr") == 0) + { + cmd_options->output_to_buffer_stderr = 1; + } else if (weechat_strcasecmp (argv[i], "-n") == 0) { cmd_options->output_to_buffer = 0; @@ -426,6 +430,7 @@ exec_command_run (struct t_gui_buffer *buffer, cmd_options.ptr_buffer = buffer; cmd_options.output_to_buffer = 0; cmd_options.output_to_buffer_exec_cmd = 0; + cmd_options.output_to_buffer_stderr = 0; cmd_options.new_buffer = 0; cmd_options.new_buffer_clear = 0; cmd_options.switch_to_buffer = 1; @@ -585,6 +590,7 @@ exec_command_run (struct t_gui_buffer *buffer, } new_exec_cmd->output_to_buffer = cmd_options.output_to_buffer; new_exec_cmd->output_to_buffer_exec_cmd = cmd_options.output_to_buffer_exec_cmd; + new_exec_cmd->output_to_buffer_stderr = cmd_options.output_to_buffer_stderr; new_exec_cmd->line_numbers = (cmd_options.line_numbers < 0) ? cmd_options.new_buffer : cmd_options.line_numbers; new_exec_cmd->color = cmd_options.color; @@ -831,7 +837,7 @@ exec_command_init () N_("execute external commands"), N_("-list" " || [-sh|-nosh] [-bg|-nobg] [-stdin|-nostdin] [-buffer <name>] " - "[-l|-o|-oc|-n|-nf] [-cl|-nocl] [-sw|-nosw] [-ln|-noln] " + "[-l|-o|-oc|-n|-nf] [-oerr] [-cl|-nocl] [-sw|-nosw] [-ln|-noln] " "[-flush|-noflush] [-color ansi|auto|irc|weechat|strip] [-rc|-norc] " "[-timeout <timeout>] [-name <name>] [-pipe <command>] " "[-hsignal <name>] <command>" @@ -870,6 +876,8 @@ exec_command_init () " -nf: display output of command in a new buffer with free " "content (no word-wrap, no limit on number of lines) (not compatible " "with options -bg/-pipe/-hsignal)\n" + " -oerr: also send stderr (error output) to the buffer (can be " + "used only with options -o and -oc)\n" " -cl: clear the new buffer before displaying output\n" " -nocl: append to the new buffer without clear (default)\n" " -sw: switch to the output buffer (default)\n" diff --git a/src/plugins/exec/exec-command.h b/src/plugins/exec/exec-command.h index 7682ead32..d1333d5f6 100644 --- a/src/plugins/exec/exec-command.h +++ b/src/plugins/exec/exec-command.h @@ -31,6 +31,7 @@ struct t_exec_cmd_options struct t_gui_buffer *ptr_buffer; /* pointer to buffer */ int output_to_buffer; /* 1 if output is sent to buffer */ int output_to_buffer_exec_cmd; /* execute commands found */ + int output_to_buffer_stderr; /* 1 if stderr is sent to buffer */ int new_buffer; /* 1=new buffer, 2=new buf. free cont*/ int new_buffer_clear; /* 1 to clear buffer before output */ int switch_to_buffer; /* switch to the output buffer */ diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c index 44544628d..5daf7ec83 100644 --- a/src/plugins/exec/exec.c +++ b/src/plugins/exec/exec.c @@ -131,6 +131,7 @@ exec_add () new_exec_cmd->end_time = 0; new_exec_cmd->output_to_buffer = 0; new_exec_cmd->output_to_buffer_exec_cmd = 0; + new_exec_cmd->output_to_buffer_stderr = 0; new_exec_cmd->buffer_full_name = NULL; new_exec_cmd->line_numbers = 0; new_exec_cmd->display_rc = 0; @@ -253,6 +254,13 @@ exec_display_line (struct t_exec_cmd *exec_cmd, struct t_gui_buffer *buffer, if (exec_cmd->output_to_buffer && !exec_cmd->pipe_command && !buffer) return; + /* if output is sent to the buffer, we send stderr only if it was asked */ + if (exec_cmd->output_to_buffer && (out == EXEC_STDERR) + && !exec_cmd->output_to_buffer_stderr) + { + return; + } + /* decode colors */ line_color = exec_decode_color (exec_cmd, line); if (!line_color) @@ -683,6 +691,7 @@ exec_print_log () weechat_log_printf (" end_time. . . . . . . . . : %lld", (long long)ptr_exec_cmd->end_time); weechat_log_printf (" output_to_buffer. . . . . : %d", ptr_exec_cmd->output_to_buffer); weechat_log_printf (" output_to_buffer_exec_cmd : %d", ptr_exec_cmd->output_to_buffer_exec_cmd); + weechat_log_printf (" output_to_buffer_stderr . : %d", ptr_exec_cmd->output_to_buffer_stderr); weechat_log_printf (" buffer_full_name. . . . . : '%s'", ptr_exec_cmd->buffer_full_name); weechat_log_printf (" line_numbers. . . . . . . : %d", ptr_exec_cmd->line_numbers); weechat_log_printf (" display_rc. . . . . . . . : %d", ptr_exec_cmd->display_rc); diff --git a/src/plugins/exec/exec.h b/src/plugins/exec/exec.h index 26492f52f..14edae3f0 100644 --- a/src/plugins/exec/exec.h +++ b/src/plugins/exec/exec.h @@ -55,6 +55,7 @@ struct t_exec_cmd /* display */ int output_to_buffer; /* 1 if output is sent to buffer */ int output_to_buffer_exec_cmd; /* 1 if commands are executed */ + int output_to_buffer_stderr; /* 1 if stderr is sent to buffer */ char *buffer_full_name; /* buffer where output is displayed */ int line_numbers; /* 1 if lines numbers are displayed */ int color; /* what to do with ANSI colors */ |