diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-13 07:56:20 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2014-03-13 07:56:20 +0100 |
commit | 0eca1fd20bf7216a0deedf01fa08e95535d6a436 (patch) | |
tree | ff1ca713b8c68ad738198020b32a82cbb4bd1355 | |
parent | 571a7a5dbef307489b496840fcdd07ba44ee1128 (diff) | |
download | weechat-0eca1fd20bf7216a0deedf01fa08e95535d6a436.zip |
exec: add options "-rc"/"-norc" (display return code) in command /exec
-rw-r--r-- | src/plugins/exec/exec-command.c | 16 | ||||
-rw-r--r-- | src/plugins/exec/exec-command.h | 1 | ||||
-rw-r--r-- | src/plugins/exec/exec.c | 5 | ||||
-rw-r--r-- | src/plugins/exec/exec.h | 3 |
4 files changed, 21 insertions, 4 deletions
diff --git a/src/plugins/exec/exec-command.c b/src/plugins/exec/exec-command.c index b54904ab1..304e05140 100644 --- a/src/plugins/exec/exec-command.c +++ b/src/plugins/exec/exec-command.c @@ -255,6 +255,14 @@ exec_command_parse_options (struct t_exec_cmd_options *cmd_options, { cmd_options->line_numbers = 0; } + else if (weechat_strcasecmp (argv[i], "-rc") == 0) + { + cmd_options->display_rc = 1; + } + else if (weechat_strcasecmp (argv[i], "-norc") == 0) + { + cmd_options->display_rc = 0; + } else if (weechat_strcasecmp (argv[i], "-timeout") == 0) { if (i + 1 >= argc) @@ -318,6 +326,7 @@ exec_command_run (struct t_gui_buffer *buffer, cmd_options.new_buffer = 0; cmd_options.switch_to_buffer = 1; cmd_options.line_numbers = -1; + cmd_options.display_rc = 1; cmd_options.ptr_command_name = NULL; /* parse default options */ @@ -429,6 +438,7 @@ exec_command_run (struct t_gui_buffer *buffer, } new_exec_cmd->line_numbers = (cmd_options.line_numbers < 0) ? cmd_options.new_buffer : cmd_options.line_numbers; + new_exec_cmd->display_rc = cmd_options.display_rc; /* execute the command */ if (weechat_exec_plugin->debug >= 1) @@ -659,8 +669,8 @@ exec_command_init () N_("execute external commands"), N_("-list" " || [-sh|-nosh] [-bg|-nobg] [-stdin|-nostdin] [-buffer <name>] " - "[-l|-o|-n] |-sw|-nosw] [-ln|-noln] [-timeout <timeout>] " - "[-name <name>] <command>" + "[-l|-o|-n] |-sw|-nosw] [-ln|-noln] [-rc|-norc] " + "[-timeout <timeout>] [-name <name>] <command>" " || -in <id> <text>" " || -inclose <id> [<text>]" " || -signal <id> <signal>" @@ -691,6 +701,8 @@ exec_command_init () " -nosw: don't switch to the output buffer\n" " -ln: display line numbers (default in new buffer only)\n" " -noln: don't display line numbers\n" + " -rc: display return code (default)\n" + " -norc: don't display return code\n" "-timeout: set a timeout for the command (in seconds)\n" " -name: set a name for the command (to name it later with /exec)\n" " command: the command to execute; if beginning with \"url:\", the " diff --git a/src/plugins/exec/exec-command.h b/src/plugins/exec/exec-command.h index e0cfb7618..b849e6ad4 100644 --- a/src/plugins/exec/exec-command.h +++ b/src/plugins/exec/exec-command.h @@ -33,6 +33,7 @@ struct t_exec_cmd_options int new_buffer; /* output in a new buffer */ int switch_to_buffer; /* switch to the output buffer */ int line_numbers; /* 1 to display line numbers */ + int display_rc; /* 1 to display return code */ const char *ptr_command_name; /* name of command */ }; diff --git a/src/plugins/exec/exec.c b/src/plugins/exec/exec.c index aea5d0454..f977c3351 100644 --- a/src/plugins/exec/exec.c +++ b/src/plugins/exec/exec.c @@ -125,6 +125,7 @@ exec_add () new_exec_cmd->output_to_buffer = 0; new_exec_cmd->buffer_full_name = NULL; new_exec_cmd->line_numbers = 0; + new_exec_cmd->display_rc = 0; new_exec_cmd->stdout_size = 0; new_exec_cmd->stdout = NULL; new_exec_cmd->stderr_size = 0; @@ -268,7 +269,8 @@ exec_end_command (struct t_exec_cmd *exec_cmd, int return_code) * display return code (only if command is not detached and if output is * NOT sent to buffer) */ - if (!exec_cmd->detached && !exec_cmd->output_to_buffer) + if (!exec_cmd->detached && !exec_cmd->output_to_buffer + && exec_cmd->display_rc) { if (return_code >= 0) { @@ -434,6 +436,7 @@ exec_print_log () weechat_log_printf (" output_to_buffer. . . . : %d", ptr_exec_cmd->output_to_buffer); 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); weechat_log_printf (" stdout_size . . . . . . : %d", ptr_exec_cmd->stdout_size); weechat_log_printf (" stdout. . . . . . . . . : '%s'", ptr_exec_cmd->stdout); weechat_log_printf (" stderr_size . . . . . . : %d", ptr_exec_cmd->stderr_size); diff --git a/src/plugins/exec/exec.h b/src/plugins/exec/exec.h index 5ae32708f..0f9da1068 100644 --- a/src/plugins/exec/exec.h +++ b/src/plugins/exec/exec.h @@ -37,10 +37,11 @@ struct t_exec_cmd time_t start_time; /* start time */ time_t end_time; /* end time */ - /* buffer */ + /* display */ int output_to_buffer; /* 1 if output is sent to buffer */ char *buffer_full_name; /* buffer where output is displayed */ int line_numbers; /* 1 if lines numbers are displayed */ + int display_rc; /* 1 if return code is displayed */ /* command output */ int stdout_size; /* number of bytes in stdout */ |