From: Christian Brabandt Date: Fri, 19 Nov 2021 12:37:36 +0000 (+0000) Subject: patch 8.2.3623: "$*" is expanded to "nonomatch" X-Git-Tag: v8.2.3623 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b8d829faf04fe3706c04f7f7000054acd3254e7;p=vim patch 8.2.3623: "$*" is expanded to "nonomatch" Problem: "$*" is expanded to "nonomatch". Solution: Only add "set nonomatch" when using a csh-like shell. (Christian Brabandt, closes #9159, closes #9153) --- diff --git a/runtime/doc/map.txt b/runtime/doc/map.txt index 4d23f4a5d..b700c822e 100644 --- a/runtime/doc/map.txt +++ b/runtime/doc/map.txt @@ -1009,9 +1009,6 @@ or `unnamedplus`. The `mode()` function will return the state as it will be after applying the operator. -The `mode()` function will return the state as it will be after applying the -operator. - Here is an example for using a lambda function to create a normal-mode operator to add quotes around text in the current line: > diff --git a/src/os_unix.c b/src/os_unix.c index 0b2b5725e..fa9c5f392 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -6691,10 +6691,17 @@ mch_expand_wildcards( } 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 >"); else if (shell_style == STYLE_PRINT) diff --git a/src/testdir/test_expand.vim b/src/testdir/test_expand.vim index 86062234d..e68d55e10 100644 --- a/src/testdir/test_expand.vim +++ b/src/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') @@ -135,4 +136,9 @@ func Test_expand_filename_multicmd() %bwipe! endfunc +func Test_expandcmd_shell_nonomatch() + CheckNotMSWindows + call assert_equal('$*', expandcmd('$*')) +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 94238de76..919a802d3 100644 --- a/src/version.c +++ b/src/version.c @@ -757,6 +757,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 3623, /**/ 3622, /**/