mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 09:48:19 +00:00
vim-patch:7.4.276
Problem: The fish shell is not supported. Solution: Use begin/end instead of () for fish. (Andy Russell) https://code.google.com/p/vim/source/detail?r=a6b59ee633a355095e6473ec5e2a7d9088bfb853
This commit is contained in:
@@ -1316,8 +1316,18 @@ do_shell (
|
|||||||
/// @returns an allocated string with the shell command.
|
/// @returns an allocated string with the shell command.
|
||||||
char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
||||||
{
|
{
|
||||||
|
bool is_fish_shell =
|
||||||
|
#if defined(UNIX)
|
||||||
|
STRNCMP(invocation_path_tail(p_sh, NULL), "fish", 4) == 0;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
|
||||||
size_t len = STRLEN(cmd) + 1; // At least enough space for cmd + NULL.
|
size_t len = STRLEN(cmd) + 1; // At least enough space for cmd + NULL.
|
||||||
len += sizeof("("")") - 1;
|
|
||||||
|
len += is_fish_shell ? sizeof("begin; ""; end") - 1
|
||||||
|
: sizeof("("")") - 1;
|
||||||
|
|
||||||
if (itmp != NULL)
|
if (itmp != NULL)
|
||||||
len += STRLEN(itmp) + sizeof(" { "" < "" } ") - 1;
|
len += STRLEN(itmp) + sizeof(" { "" < "" } ") - 1;
|
||||||
if (otmp != NULL)
|
if (otmp != NULL)
|
||||||
@@ -1325,18 +1335,22 @@ char_u *make_filter_cmd(char_u *cmd, char_u *itmp, char_u *otmp)
|
|||||||
char_u *buf = xmalloc(len);
|
char_u *buf = xmalloc(len);
|
||||||
|
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
// Put braces around the command (for concatenated commands) when
|
// Put delimiters around the command (for concatenated commands) when
|
||||||
// redirecting input and/or output.
|
// redirecting input and/or output.
|
||||||
if (itmp != NULL || otmp != NULL)
|
if (itmp != NULL || otmp != NULL) {
|
||||||
vim_snprintf((char *)buf, len, "(%s)", (char *)cmd);
|
char *fmt = is_fish_shell ? "begin; %s; end"
|
||||||
else
|
: "(%s)";
|
||||||
|
vim_snprintf((char *)buf, len, fmt, (char *)cmd);
|
||||||
|
} else {
|
||||||
STRCPY(buf, cmd);
|
STRCPY(buf, cmd);
|
||||||
|
}
|
||||||
|
|
||||||
if (itmp != NULL) {
|
if (itmp != NULL) {
|
||||||
STRCAT(buf, " < ");
|
STRCAT(buf, " < ");
|
||||||
STRCAT(buf, itmp);
|
STRCAT(buf, itmp);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// for shells that don't understand braces around commands, at least allow
|
// For shells that don't understand braces around commands, at least allow
|
||||||
// the use of commands in a pipe.
|
// the use of commands in a pipe.
|
||||||
STRCPY(buf, cmd);
|
STRCPY(buf, cmd);
|
||||||
if (itmp != NULL) {
|
if (itmp != NULL) {
|
||||||
|
@@ -2359,7 +2359,6 @@ void set_init_3(void)
|
|||||||
* This is done after other initializations, where 'shell' might have been
|
* This is done after other initializations, where 'shell' might have been
|
||||||
* set, but only if they have not been set before.
|
* set, but only if they have not been set before.
|
||||||
*/
|
*/
|
||||||
char_u *p;
|
|
||||||
int idx_srr;
|
int idx_srr;
|
||||||
int do_srr;
|
int do_srr;
|
||||||
int idx_sp;
|
int idx_sp;
|
||||||
@@ -2376,28 +2375,10 @@ void set_init_3(void)
|
|||||||
else
|
else
|
||||||
do_sp = !(options[idx_sp].flags & P_WAS_SET);
|
do_sp = !(options[idx_sp].flags & P_WAS_SET);
|
||||||
|
|
||||||
/*
|
size_t len = 0;
|
||||||
* Isolate the name of the shell:
|
char_u *p = (char_u *)invocation_path_tail(p_sh, &len);
|
||||||
* - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
|
p = vim_strnsave(p, len);
|
||||||
* - Remove any argument. E.g., "csh -f" -> "csh".
|
|
||||||
* But don't allow a space in the path, so that this works:
|
|
||||||
* "/usr/bin/csh --rcfile ~/.cshrc"
|
|
||||||
* But don't do that for Windows, it's common to have a space in the path.
|
|
||||||
*/
|
|
||||||
p = skiptowhite(p_sh);
|
|
||||||
if (*p == NUL) {
|
|
||||||
/* No white space, use the tail. */
|
|
||||||
p = vim_strsave(path_tail(p_sh));
|
|
||||||
} else {
|
|
||||||
char_u *p1, *p2;
|
|
||||||
|
|
||||||
/* Find the last path separator before the space. */
|
|
||||||
p1 = p_sh;
|
|
||||||
for (p2 = p_sh; p2 < p; mb_ptr_adv(p2))
|
|
||||||
if (vim_ispathsep(*p2))
|
|
||||||
p1 = p2 + 1;
|
|
||||||
p = vim_strnsave(p1, (int)(p - p1));
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Default for p_sp is "| tee", for p_srr is ">".
|
* Default for p_sp is "| tee", for p_srr is ">".
|
||||||
@@ -2421,6 +2402,7 @@ void set_init_3(void)
|
|||||||
|| fnamecmp(p, "zsh") == 0
|
|| fnamecmp(p, "zsh") == 0
|
||||||
|| fnamecmp(p, "zsh-beta") == 0
|
|| fnamecmp(p, "zsh-beta") == 0
|
||||||
|| fnamecmp(p, "bash") == 0
|
|| fnamecmp(p, "bash") == 0
|
||||||
|
|| fnamecmp(p, "fish") == 0
|
||||||
) {
|
) {
|
||||||
if (do_sp) {
|
if (do_sp) {
|
||||||
p_sp = (char_u *)"2>&1| tee";
|
p_sp = (char_u *)"2>&1| tee";
|
||||||
|
@@ -319,7 +319,7 @@ static int included_patches[] = {
|
|||||||
//279,
|
//279,
|
||||||
//278,
|
//278,
|
||||||
277,
|
277,
|
||||||
//276,
|
276,
|
||||||
275,
|
275,
|
||||||
274,
|
274,
|
||||||
//273 NA
|
//273 NA
|
||||||
|
Reference in New Issue
Block a user