mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
make backtick-expansion work with shell=fish
This commit is contained in:
parent
483e8257e5
commit
8f0f1a76c2
@ -202,6 +202,13 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
|
|||||||
static char *sh_vimglob_func =
|
static char *sh_vimglob_func =
|
||||||
"vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
|
"vimglob() { while [ $# -ge 1 ]; do echo \"$1\"; shift; done }; vimglob >";
|
||||||
|
|
||||||
|
bool is_fish_shell =
|
||||||
|
#if defined(UNIX)
|
||||||
|
STRNCMP(invocation_path_tail(p_sh, NULL), "fish", 4) == 0;
|
||||||
|
#else
|
||||||
|
false;
|
||||||
|
#endif
|
||||||
|
|
||||||
*num_file = 0; /* default: no files found */
|
*num_file = 0; /* default: no files found */
|
||||||
*file = NULL;
|
*file = NULL;
|
||||||
|
|
||||||
@ -281,6 +288,11 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
|
|||||||
++len;
|
++len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_fish_shell) {
|
||||||
|
len += sizeof("egin;"" end") - 1;
|
||||||
|
}
|
||||||
|
|
||||||
command = xmalloc(len);
|
command = xmalloc(len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -293,10 +305,19 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file,
|
|||||||
*/
|
*/
|
||||||
if (shell_style == STYLE_BT) {
|
if (shell_style == STYLE_BT) {
|
||||||
/* change `command; command& ` to (command; command ) */
|
/* change `command; command& ` to (command; command ) */
|
||||||
|
if (is_fish_shell) {
|
||||||
|
STRCPY(command, "begin; ");
|
||||||
|
} else {
|
||||||
STRCPY(command, "(");
|
STRCPY(command, "(");
|
||||||
|
}
|
||||||
STRCAT(command, pat[0] + 1); /* exclude first backtick */
|
STRCAT(command, pat[0] + 1); /* exclude first backtick */
|
||||||
p = command + STRLEN(command) - 1;
|
p = command + STRLEN(command) - 1;
|
||||||
|
if (is_fish_shell) {
|
||||||
|
*p-- = ';';
|
||||||
|
STRCAT(command, " end");
|
||||||
|
} else {
|
||||||
*p-- = ')'; /* remove last backtick */
|
*p-- = ')'; /* remove last backtick */
|
||||||
|
}
|
||||||
while (p > command && ascii_iswhite(*p))
|
while (p > command && ascii_iswhite(*p))
|
||||||
--p;
|
--p;
|
||||||
if (*p == '&') { /* remove trailing '&' */
|
if (*p == '&') { /* remove trailing '&' */
|
||||||
|
Loading…
Reference in New Issue
Block a user