0
0
mirror of https://github.com/vim/vim.git synced 2025-10-08 06:04:08 -04:00

updated for version 7.4.276

Problem:    The fish shell is not supported.
Solution:   Use begin/end instead of () for fish. (Andy Russell)
This commit is contained in:
Bram Moolenaar
2014-05-07 15:10:21 +02:00
parent f4d7f167f3
commit 75a8d74cc2
5 changed files with 65 additions and 40 deletions

View File

@@ -1551,7 +1551,15 @@ make_filter_cmd(cmd, itmp, otmp)
{ {
char_u *buf; char_u *buf;
long_u len; long_u len;
int is_fish_shell;
#if (defined(UNIX) && !defined(ARCHIE)) || defined(OS2)
/* Account for fish's different syntax for subshells */
is_fish_shell = (fnamecmp(get_isolated_shell_name(), "fish") == 0);
if (is_fish_shell)
len = (long_u)STRLEN(cmd) + 13; /* "begin; " + "; end" + NUL */
else
#endif
len = (long_u)STRLEN(cmd) + 3; /* "()" + NUL */ len = (long_u)STRLEN(cmd) + 3; /* "()" + NUL */
if (itmp != NULL) if (itmp != NULL)
len += (long_u)STRLEN(itmp) + 9; /* " { < " + " } " */ len += (long_u)STRLEN(itmp) + 9; /* " { < " + " } " */
@@ -1567,7 +1575,12 @@ make_filter_cmd(cmd, itmp, otmp)
* redirecting input and/or output. * redirecting input and/or output.
*/ */
if (itmp != NULL || otmp != NULL) if (itmp != NULL || otmp != NULL)
{
if (is_fish_shell)
vim_snprintf((char *)buf, len, "begin; %s; end", (char *)cmd);
else
vim_snprintf((char *)buf, len, "(%s)", (char *)cmd); vim_snprintf((char *)buf, len, "(%s)", (char *)cmd);
}
else else
STRCPY(buf, cmd); STRCPY(buf, cmd);
if (itmp != NULL) if (itmp != NULL)
@@ -1577,7 +1590,7 @@ make_filter_cmd(cmd, itmp, otmp)
} }
#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);

View File

@@ -10896,3 +10896,41 @@ goto_im()
{ {
return (p_im && stuff_empty() && typebuf_typed()); return (p_im && stuff_empty() && typebuf_typed());
} }
/*
* Returns the isolated name of the shell:
* - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
* - 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.
*/
char_u *
get_isolated_shell_name()
{
char_u *p;
#ifdef WIN3264
p = gettail(p_sh);
p = vim_strnsave(p, (int)(skiptowhite(p) - p));
#else
p = skiptowhite(p_sh);
if (*p == NUL)
{
/* No white space, use the tail. */
p = vim_strsave(gettail(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));
}
#endif
return p;
}

View File

@@ -3804,37 +3804,7 @@ set_init_3()
else else
do_sp = !(options[idx_sp].flags & P_WAS_SET); do_sp = !(options[idx_sp].flags & P_WAS_SET);
#endif #endif
p = get_isolated_shell_name();
/*
* Isolate the name of the shell:
* - Skip beyond any path. E.g., "/usr/bin/csh -f" -> "csh -f".
* - 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.
*/
#ifdef WIN3264
p = gettail(p_sh);
p = vim_strnsave(p, (int)(skiptowhite(p) - p));
#else
p = skiptowhite(p_sh);
if (*p == NUL)
{
/* No white space, use the tail. */
p = vim_strsave(gettail(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));
}
#endif
if (p != NULL) if (p != NULL)
{ {
/* /*
@@ -3875,6 +3845,7 @@ set_init_3()
|| 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
# ifdef WIN3264 # ifdef WIN3264
|| fnamecmp(p, "cmd") == 0 || fnamecmp(p, "cmd") == 0
|| fnamecmp(p, "sh.exe") == 0 || fnamecmp(p, "sh.exe") == 0

View File

@@ -103,4 +103,5 @@ void addfile __ARGS((garray_T *gap, char_u *f, int flags));
char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags, int *ret_len)); char_u *get_cmd_output __ARGS((char_u *cmd, char_u *infile, int flags, int *ret_len));
void FreeWild __ARGS((int count, char_u **files)); void FreeWild __ARGS((int count, char_u **files));
int goto_im __ARGS((void)); int goto_im __ARGS((void));
char_u *get_isolated_shell_name __ARGS((void));
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -734,6 +734,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
276,
/**/ /**/
275, 275,
/**/ /**/