# HG changeset patch # User Bram Moolenaar # Date 1660582803 -7200 # Node ID 32f358d71ec28f93416858945f278689ffde0907 # Parent dc388902b2f71994a0644ecda7a3c2d971be64d8 patch 9.0.0217: 'shellslash' works differently when sourcing a script again Commit: https://github.com/vim/vim/commit/5a4fff4d948cd12a5cf5f637ad2c561815a77d8e Author: zeertzjq Date: Mon Aug 15 17:53:55 2022 +0100 patch 9.0.0217: 'shellslash' works differently when sourcing a script again Problem: 'shellslash' works differently when sourcing a script again. Solution: Use the name from the script item. (closes https://github.com/vim/vim/issues/10920) diff --git a/src/scriptfile.c b/src/scriptfile.c --- a/src/scriptfile.c +++ b/src/scriptfile.c @@ -1534,10 +1534,6 @@ do_source_ext( cookie.level = ex_nesting_level; #endif - // Keep the sourcing name/lnum, for recursive calls. - estack_push(ETYPE_SCRIPT, fname_exp, 0); - ESTACK_CHECK_SETUP - #ifdef STARTUPTIME if (time_fd != NULL) time_push(&tv_rel, &tv_start); @@ -1630,6 +1626,10 @@ do_source_ext( si->sn_is_vimrc = is_vimrc; } + // Keep the sourcing name/lnum, for recursive calls. + estack_push(ETYPE_SCRIPT, si->sn_name, 0); + ESTACK_CHECK_SETUP + # ifdef FEAT_PROFILE if (do_profiling == PROF_YES) { diff --git a/src/testdir/test_expand_func.vim b/src/testdir/test_expand_func.vim --- a/src/testdir/test_expand_func.vim +++ b/src/testdir/test_expand_func.vim @@ -41,7 +41,7 @@ func Test_expand_sfile_and_stack() call assert_match('test_expand_func\.vim$', s:sfile) let expected = 'script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack' call assert_match(expected .. '$', expand('')) - call assert_match(expected .. '\[4\]' , expand('')) + call assert_match(expected .. '\[4\]$' , expand('')) " Call in script-local function call assert_match('script .*testdir/runtest.vim\[\d\+\]\.\.function RunTheTest\[\d\+\]\.\.Test_expand_sfile_and_stack\[7\]\.\.\d\+_expand_sfile$', s:expand_sfile()) @@ -59,7 +59,32 @@ func Test_expand_sfile_and_stack() call writefile(lines, 'Xstack') source Xstack call assert_match('\') + set noshellslash + let g:stack2 = expand('') + set shellslash + let g:stack3 = expand('') + END + call writefile(lines, 'Xshellslash/Xstack') + " Test that changing 'shellslash' always affects the result of expand() + " when sourcing a script multiple times. + for i in range(2) + source Xshellslash/Xstack + call assert_match('\