diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2015-01-30 08:58:37 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2015-01-30 08:58:37 +0100 |
commit | 5e2cd75efc5faa206d0c8623ee15284a7f79f1fc (patch) | |
tree | 31885db2a6b4a2900226e3c545ebc35d030fe2a2 /src | |
parent | d3c309c7874dcfa98bbbcf1290f935013d344e55 (diff) | |
download | weechat-5e2cd75efc5faa206d0c8623ee15284a7f79f1fc.zip |
core: add option "-s" in command /eval to split commands (no more split by default) (closes #324)
Diffstat (limited to 'src')
-rw-r--r-- | src/core/wee-command.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c index 9e79d7b91..176642a96 100644 --- a/src/core/wee-command.c +++ b/src/core/wee-command.c @@ -1815,7 +1815,7 @@ COMMAND_CALLBACK(debug) COMMAND_CALLBACK(eval) { - int i, print_only, condition; + int i, print_only, split_command, condition; char *result, *ptr_args, *expr, **commands; struct t_hashtable *pointers, *options; @@ -1824,6 +1824,7 @@ COMMAND_CALLBACK(eval) (void) argv; print_only = 0; + split_command = 0; condition = 0; COMMAND_MIN_ARGS(2, ""); @@ -1836,6 +1837,11 @@ COMMAND_CALLBACK(eval) print_only = 1; ptr_args = argv_eol[i + 1]; } + else if (string_strcasecmp (argv[i], "-s") == 0) + { + split_command = 1; + ptr_args = argv_eol[i + 1]; + } else if (string_strcasecmp (argv[i], "-c") == 0) { condition = 1; @@ -1906,14 +1912,21 @@ COMMAND_CALLBACK(eval) result = eval_expression (ptr_args, pointers, NULL, options); if (result) { - commands = string_split_command (result, ';'); - if (commands) + if (split_command) { - for (i = 0; commands[i]; i++) + commands = string_split_command (result, ';'); + if (commands) { - (void) input_data (buffer, commands[i]); + for (i = 0; commands[i]; i++) + { + (void) input_data (buffer, commands[i]); + } + string_free_split_command (commands); } - string_free_split_command (commands); + } + else + { + (void) input_data (buffer, result); } } else @@ -7105,8 +7118,12 @@ command_init () hook_command ( NULL, "eval", N_("evaluate expression"), - N_("[-n] <expression> || [-n] -c <expression1> <operator> <expression2>"), - N_(" -n: display result without sending it to buffer (debug mode)\n" + N_("[-n|-s] <expression>" + " || [-n] -c <expression1> <operator> <expression2>"), + N_(" -n: display result without sending it to buffer " + "(debug mode)\n" + " -s: split expression (many commands can be separated by " + "semicolons)\n" " -c: evaluate as condition: use operators and parentheses, " "return a boolean value (\"0\" or \"1\")\n" "expression: expression to evaluate, variables with format " @@ -7178,7 +7195,7 @@ command_init () " /eval -n -c abcd =~ (?-i)^ABC ==> 0\n" " /eval -n -c abcd =~ (?-i)^abc ==> 1\n" " /eval -n -c abcd !~ abc ==> 0"), - "-n|-c -n|-c", + "-n|-s|-c -n|-s|-c", &command_eval, NULL); hook_command ( NULL, "filter", |