mirror of
https://github.com/weechat/weechat.git
synced 2026-06-28 05:46:38 +02:00
exec: add option "-oerr" to send stderr to buffer (now disabled by default) (closes #1566)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user