aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcos Almeida <maurelio1234@users.noreply.github.com>2018-07-29 03:49:11 +0200
committerJustin M. Keyes <justinkz@gmail.com>2018-07-29 03:49:11 +0200
commita2253744c9bcd9229be9533540075e977f0be2cd (patch)
tree070c1e53b0578e99bcb0b8dcb2c56b5b7b821ba8 /src
parentbefc7de26f2907fdf0c61b883c68c7a64432aa03 (diff)
downloadrneovim-a2253744c9bcd9229be9533540075e977f0be2cd.tar.gz
rneovim-a2253744c9bcd9229be9533540075e977f0be2cd.tar.bz2
rneovim-a2253744c9bcd9229be9533540075e977f0be2cd.zip
system(): handle profiling and 'verbose' #8730
closes #8362 Vim's code calls `call_shell` directly from `get_system_output_as_rettv` whereas in Nvim this function has been rewritten to not call `call_shell` but to call `os_system` via `do_os_system`, losing the support for profiling and verbose. Changing the code to call `call_shell` from `get_system_output_as_rettv` seems to be too complicated to be worth it on the current version of the code. So this commit duplicates the relevant code.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 1ba516a29c..3843245070 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -16401,9 +16401,12 @@ static list_T *string_to_list(const char *str, size_t len, const bool keepempty)
return list;
}
+// os_system wrapper. Handles 'verbose', :profile, and v:shell_error.
static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
bool retlist)
{
+ proftime_T wait_time;
+
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
@@ -16430,11 +16433,29 @@ static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
return; // Already did emsg.
}
+ if (p_verbose > 3) {
+ char buf[NUMBUFLEN];
+ const char * cmd = tv_get_string_buf(argvars, buf);
+
+ verbose_enter_scroll();
+ smsg(_("Calling shell to execute: \"%s\""), cmd);
+ msg_puts("\n\n");
+ verbose_leave_scroll();
+ }
+
+ if (do_profiling == PROF_YES) {
+ prof_child_enter(&wait_time);
+ }
+
// execute the command
size_t nread = 0;
char *res = NULL;
int status = os_system(argv, input, input_len, &res, &nread);
+ if (do_profiling == PROF_YES) {
+ prof_child_exit(&wait_time);
+ }
+
xfree(input);
set_vim_var_nr(VV_SHELL_ERROR, (long) status);