From d3c6f1ebbb528dd526daa6b3cbf3007d65f2af17 Mon Sep 17 00:00:00 2001 From: Jason Cox Date: Wed, 1 Sep 2021 21:46:27 -0600 Subject: [PATCH] vim-patch:8.2.3393: escaping for fish shell is skipping some characters Problem: Escaping for fish shell is skipping some characters. Solution: Escape character after backslash if needed. (Jason Cox, closes vim/vim#8827) https://github.com/vim/vim/commit/6631597452d4644f485a09e4036d117e5f91de70 --- src/nvim/strings.c | 1 + src/nvim/testdir/test_functions.vim | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/nvim/strings.c b/src/nvim/strings.c index 33310701d5..79a3db4843 100644 --- a/src/nvim/strings.c +++ b/src/nvim/strings.c @@ -278,6 +278,7 @@ char_u *vim_strsave_shellescape(const char_u *string, if (*p == '\\' && fish_like) { *d++ = '\\'; *d++ = *p++; + continue; } MB_COPY_CHAR(p, d); diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim index c964f7aea4..b35a210055 100644 --- a/src/nvim/testdir/test_functions.vim +++ b/src/nvim/testdir/test_functions.vim @@ -1174,6 +1174,14 @@ func Test_shellescape() call assert_equal("'te\\\\xt'", shellescape("te\\xt")) call assert_equal("'te\\\\xt'", shellescape("te\\xt", 1)) + call assert_equal("'te\\\\'\\''xt'", shellescape("te\\'xt")) + call assert_equal("'te\\\\'\\''xt'", shellescape("te\\'xt", 1)) + call assert_equal("'te\\\\!xt'", shellescape("te\\!xt")) + call assert_equal("'te\\\\\\!xt'", shellescape("te\\!xt", 1)) + call assert_equal("'te\\\\%xt'", shellescape("te\\%xt")) + call assert_equal("'te\\\\\\%xt'", shellescape("te\\%xt", 1)) + call assert_equal("'te\\\\#xt'", shellescape("te\\#xt")) + call assert_equal("'te\\\\\\#xt'", shellescape("te\\#xt", 1)) let &shell = save_shell endfunc