aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/misc1.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/misc1.c')
-rw-r--r--src/nvim/misc1.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index cab4edfec8..4ab059c923 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -31,7 +31,6 @@
#include "nvim/memline.h"
#include "nvim/memory.h"
#include "nvim/message.h"
-#include "nvim/misc2.h"
#include "nvim/garray.h"
#include "nvim/move.h"
#include "nvim/mouse.h"
@@ -41,6 +40,7 @@
#include "nvim/regexp.h"
#include "nvim/screen.h"
#include "nvim/search.h"
+#include "nvim/state.h"
#include "nvim/strings.h"
#include "nvim/tag.h"
#include "nvim/ui.h"
@@ -1746,18 +1746,6 @@ int gchar_pos(pos_T *pos)
}
/*
- * Skip to next part of an option argument: Skip space and comma.
- */
-char_u *skip_to_option_part(char_u *p)
-{
- if (*p == ',')
- ++p;
- while (*p == ' ')
- ++p;
- return p;
-}
-
-/*
* Call this function when something in the current buffer is changed.
*
* Most often called through changed_bytes() and changed_lines(), which also
@@ -2691,6 +2679,42 @@ void fast_breakcheck(void)
}
}
+// Call shell. Calls os_call_shell, with 'shellxquote' added.
+int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
+{
+ int retval;
+ proftime_T wait_time;
+
+ if (p_verbose > 3) {
+ verbose_enter();
+ smsg(_("Calling shell to execute: \"%s\""),
+ cmd == NULL ? p_sh : cmd);
+ ui_putc('\n');
+ verbose_leave();
+ }
+
+ if (do_profiling == PROF_YES) {
+ prof_child_enter(&wait_time);
+ }
+
+ if (*p_sh == NUL) {
+ EMSG(_(e_shellempty));
+ retval = -1;
+ } else {
+ // The external command may update a tags file, clear cached tags.
+ tag_freematch();
+
+ retval = os_call_shell(cmd, opts, extra_shell_arg);
+ }
+
+ set_vim_var_nr(VV_SHELL_ERROR, (varnumber_T)retval);
+ if (do_profiling == PROF_YES) {
+ prof_child_exit(&wait_time);
+ }
+
+ return retval;
+}
+
/// Get the stdout of an external command.
/// If "ret_len" is NULL replace NUL characters with NL. When "ret_len" is not
/// NULL store the length there.