diff options
author | raichoo <raichoo@googlemail.com> | 2017-03-05 17:04:19 +0100 |
---|---|---|
committer | raichoo <raichoo@googlemail.com> | 2017-03-06 13:18:24 +0100 |
commit | 8f0f1a76c25e4ecf3b1501536733174cb79f2b7d (patch) | |
tree | 94889e8008137a3c177c141045284d40266a78fe /src/nvim/os_unix.c | |
parent | 483e8257e5a28893bcd1de089715f82798d0f93a (diff) | |
download | rneovim-8f0f1a76c25e4ecf3b1501536733174cb79f2b7d.tar.gz rneovim-8f0f1a76c25e4ecf3b1501536733174cb79f2b7d.tar.bz2 rneovim-8f0f1a76c25e4ecf3b1501536733174cb79f2b7d.zip |
make backtick-expansion work with `shell=fish`
Diffstat (limited to 'src/nvim/os_unix.c')
-rw-r--r-- | src/nvim/os_unix.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 08294fa6a0..7f926cf315 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -202,6 +202,13 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, static char *sh_vimglob_func = "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 */ *file = NULL; @@ -281,6 +288,11 @@ int mch_expand_wildcards(int num_pat, char_u **pat, int *num_file, ++len; } } + + if (is_fish_shell) { + len += sizeof("egin;"" end") - 1; + } + 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) { /* change `command; command& ` to (command; command ) */ - STRCPY(command, "("); + if (is_fish_shell) { + STRCPY(command, "begin; "); + } else { + STRCPY(command, "("); + } STRCAT(command, pat[0] + 1); /* exclude first backtick */ p = command + STRLEN(command) - 1; - *p-- = ')'; /* remove last backtick */ + if (is_fish_shell) { + *p-- = ';'; + STRCAT(command, " end"); + } else { + *p-- = ')'; /* remove last backtick */ + } while (p > command && ascii_iswhite(*p)) --p; if (*p == '&') { /* remove trailing '&' */ |