Make extra_shell_arg a mch_call_shell parameter

This commit is contained in:
Thiago de Arruda
2014-03-29 12:53:11 -03:00
parent 8a61c27b1e
commit c791922224
8 changed files with 15 additions and 16 deletions

View File

@@ -840,7 +840,7 @@ static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff)
tmp_orig, tmp_new); tmp_orig, tmp_new);
append_redir(cmd, (int)len, p_srr, tmp_diff); append_redir(cmd, (int)len, p_srr, tmp_diff);
block_autocmds(); /* Avoid ShellCmdPost stuff */ block_autocmds(); /* Avoid ShellCmdPost stuff */
(void)call_shell(cmd, SHELL_FILTER | SHELL_SILENT | SHELL_DOOUT); (void)call_shell(cmd, SHELL_FILTER | SHELL_SILENT | SHELL_DOOUT, NULL);
unblock_autocmds(); unblock_autocmds();
vim_free(cmd); vim_free(cmd);
} }
@@ -943,7 +943,7 @@ void ex_diffpatch(exarg_T *eap)
#endif // ifdef UNIX #endif // ifdef UNIX
// Avoid ShellCmdPost stuff // Avoid ShellCmdPost stuff
block_autocmds(); block_autocmds();
(void)call_shell(buf, SHELL_FILTER | SHELL_COOKED); (void)call_shell(buf, SHELL_FILTER | SHELL_COOKED, NULL);
unblock_autocmds(); unblock_autocmds();
} }

View File

@@ -1102,7 +1102,7 @@ do_filter (
* like ":r !cat" hangs. * like ":r !cat" hangs.
* Pass on the SHELL_DOOUT flag when the output is being redirected. * Pass on the SHELL_DOOUT flag when the output is being redirected.
*/ */
if (call_shell(cmd_buf, SHELL_FILTER | SHELL_COOKED | shell_flags)) { if (call_shell(cmd_buf, SHELL_FILTER | SHELL_COOKED | shell_flags, NULL)) {
redraw_later_clear(); redraw_later_clear();
wait_return(FALSE); wait_return(FALSE);
} }
@@ -1256,7 +1256,7 @@ do_shell (
if (!swapping_screen()) if (!swapping_screen())
windgoto(msg_row, msg_col); windgoto(msg_row, msg_col);
cursor_on(); cursor_on();
(void)call_shell(cmd, SHELL_COOKED | flags); (void)call_shell(cmd, SHELL_COOKED | flags, NULL);
did_check_timestamps = FALSE; did_check_timestamps = FALSE;
need_check_timestamps = TRUE; need_check_timestamps = TRUE;

View File

@@ -3670,7 +3670,7 @@ get_cmd_output (
* Don't check timestamps here. * Don't check timestamps here.
*/ */
++no_check_timestamps; ++no_check_timestamps;
call_shell(command, SHELL_DOOUT | SHELL_EXPAND | flags); call_shell(command, SHELL_DOOUT | SHELL_EXPAND | flags, NULL);
--no_check_timestamps; --no_check_timestamps;
vim_free(command); vim_free(command);

View File

@@ -1531,7 +1531,7 @@ int default_fileformat(void)
/* /*
* Call shell. Calls mch_call_shell, with 'shellxquote' added. * Call shell. Calls mch_call_shell, with 'shellxquote' added.
*/ */
int call_shell(char_u *cmd, int opt) int call_shell(char_u *cmd, int opt, char_u *extra_shell_arg)
{ {
char_u *ncmd; char_u *ncmd;
int retval; int retval;
@@ -1557,7 +1557,7 @@ int call_shell(char_u *cmd, int opt)
tag_freematch(); tag_freematch();
if (cmd == NULL || *p_sxq == NUL) if (cmd == NULL || *p_sxq == NUL)
retval = mch_call_shell(cmd, opt); retval = mch_call_shell(cmd, opt, extra_shell_arg);
else { else {
char_u *ecmd = cmd; char_u *ecmd = cmd;
@@ -1575,7 +1575,7 @@ int call_shell(char_u *cmd, int opt)
STRCAT(ncmd, STRCMP(p_sxq, "(") == 0 ? (char_u *)")" STRCAT(ncmd, STRCMP(p_sxq, "(") == 0 ? (char_u *)")"
: STRCMP(p_sxq, "\"(") == 0 ? (char_u *)")\"" : STRCMP(p_sxq, "\"(") == 0 ? (char_u *)")\""
: p_sxq); : p_sxq);
retval = mch_call_shell(ncmd, opt); retval = mch_call_shell(ncmd, opt, extra_shell_arg);
vim_free(ncmd); vim_free(ncmd);
} else } else
retval = -1; retval = -1;

View File

@@ -64,7 +64,7 @@ int get_fileformat(buf_T *buf);
int get_fileformat_force(buf_T *buf, exarg_T *eap); int get_fileformat_force(buf_T *buf, exarg_T *eap);
void set_fileformat(int t, int opt_flags); void set_fileformat(int t, int opt_flags);
int default_fileformat(void); int default_fileformat(void);
int call_shell(char_u *cmd, int opt); int call_shell(char_u *cmd, int opt, char_u *extra_shell_arg);
int get_real_state(void); int get_real_state(void);
int after_pathsep(char_u *b, char_u *p); int after_pathsep(char_u *b, char_u *p);
int same_directory(char_u *f1, char_u *f2); int same_directory(char_u *f1, char_u *f2);

View File

@@ -53,3 +53,5 @@ int shell_count_argc(char_u **ptr)
return rv; return rv;
} }
char ** shell_build_argv(char_u **ptr, int argc);

View File

@@ -143,7 +143,6 @@ static int save_patterns(int num_pat, char_u **pat, int *num_file,
/* volatile because it is used in signal handler sig_winch(). */ /* volatile because it is used in signal handler sig_winch(). */
static volatile int do_resize = FALSE; static volatile int do_resize = FALSE;
static char_u *extra_shell_arg = NULL;
static int show_shell_mess = TRUE; static int show_shell_mess = TRUE;
/* volatile because it is used in signal handler deathtrap(). */ /* volatile because it is used in signal handler deathtrap(). */
static volatile int deadly_signal = 0; /* The signal we caught */ static volatile int deadly_signal = 0; /* The signal we caught */
@@ -1682,9 +1681,7 @@ waitstatus *status;
return wait_pid; return wait_pid;
} }
int mch_call_shell(cmd, options) int mch_call_shell(char_u *cmd, int options, char_u *extra_shell_arg)
char_u *cmd;
int options; /* SHELL_*, see vim.h */
{ {
int tmode = cur_tmode; int tmode = cur_tmode;
@@ -2515,6 +2512,7 @@ int flags; /* EW_* flags */
size_t len; size_t len;
char_u *p; char_u *p;
int dir; int dir;
char_u *extra_shell_arg = NULL;
/* /*
* This is the non-OS/2 implementation (really Unix). * This is the non-OS/2 implementation (really Unix).
*/ */
@@ -2715,14 +2713,13 @@ int flags; /* EW_* flags */
/* /*
* execute the shell command * execute the shell command
*/ */
i = call_shell(command, SHELL_EXPAND | SHELL_SILENT); i = call_shell(command, SHELL_EXPAND | SHELL_SILENT, extra_shell_arg);
/* When running in the background, give it some time to create the temp /* When running in the background, give it some time to create the temp
* file, but don't wait for it to finish. */ * file, but don't wait for it to finish. */
if (ampersent) if (ampersent)
os_delay(10L, TRUE); os_delay(10L, TRUE);
extra_shell_arg = NULL; /* cleanup */
show_shell_mess = TRUE; show_shell_mess = TRUE;
vim_free(command); vim_free(command);

View File

@@ -42,7 +42,7 @@ int mch_screenmode(char_u *arg);
int mch_get_shellsize(void); int mch_get_shellsize(void);
void mch_set_shellsize(void); void mch_set_shellsize(void);
void mch_new_shellsize(void); void mch_new_shellsize(void);
int mch_call_shell(char_u *cmd, int options); int mch_call_shell(char_u *cmd, int options, char_u *extra_shell_arg);
int mch_expandpath(garray_T *gap, char_u *path, int flags); int mch_expandpath(garray_T *gap, char_u *path, int flags);
int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
char_u ***file, char_u ***file,