aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/os/shell.c14
-rw-r--r--src/nvim/testdir/test_expand.vim7
2 files changed, 17 insertions, 4 deletions
diff --git a/src/nvim/os/shell.c b/src/nvim/os/shell.c
index dd44cb1ce7..b793b8f9c6 100644
--- a/src/nvim/os/shell.c
+++ b/src/nvim/os/shell.c
@@ -249,10 +249,16 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
}
STRCAT(command, ">");
} else {
- if (flags & EW_NOTFOUND) {
- STRCPY(command, "set nonomatch; ");
- } else {
- STRCPY(command, "unset nonomatch; ");
+ STRCPY(command, "");
+ if (shell_style == STYLE_GLOB) {
+ // Assume the nonomatch option is valid only for csh like shells,
+ // otherwise, this may set the positional parameters for the shell,
+ // e.g. "$*".
+ if (flags & EW_NOTFOUND) {
+ STRCAT(command, "set nonomatch; ");
+ } else {
+ STRCAT(command, "unset nonomatch; ");
+ }
}
if (shell_style == STYLE_GLOB) {
STRCAT(command, "glob >");
diff --git a/src/nvim/testdir/test_expand.vim b/src/nvim/testdir/test_expand.vim
index 383921bb82..e68d55e105 100644
--- a/src/nvim/testdir/test_expand.vim
+++ b/src/nvim/testdir/test_expand.vim
@@ -1,6 +1,7 @@
" Test for expanding file names
source shared.vim
+source check.vim
func Test_with_directories()
call mkdir('Xdir1')
@@ -131,7 +132,13 @@ func Test_expand_filename_multicmd()
call assert_equal(4, winnr('$'))
call assert_equal('foo!', bufname(winbufnr(1)))
call assert_equal('foo', bufname(winbufnr(2)))
+ call assert_fails('e %:s/.*//', 'E500:')
%bwipe!
endfunc
+func Test_expandcmd_shell_nonomatch()
+ CheckNotMSWindows
+ call assert_equal('$*', expandcmd('$*'))
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab