comparison src/testdir/test_shell.vim @ 25715:454cbc872368 v8.2.3393

patch 8.2.3393: escaping for fish shell is skipping some characters Commit: https://github.com/vim/vim/commit/6631597452d4644f485a09e4036d117e5f91de70 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Sep 1 14:31:51 2021 +0200 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 #8827)
author Bram Moolenaar <Bram@vim.org>
date Wed, 01 Sep 2021 14:45:04 +0200
parents 000b37efd5fa
children 008808e60963
comparison
equal deleted inserted replaced
25714:e62b87048b17 25715:454cbc872368
59 59
60 " Test shellescape() for each of the shells. 60 " Test shellescape() for each of the shells.
61 for e in shells 61 for e in shells
62 exe 'set shell=' .. e[0] 62 exe 'set shell=' .. e[0]
63 if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$' 63 if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$'
64 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%# \\'" 64 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%# \\'\\'' \\\\! \\% \\#'"
65 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\# \\'" 65 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\# \\'\\'' \\\\\\! \\\\% \\\\#'"
66 elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$' 66 elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$'
67 \ || e[0] =~# '.*pwsh$' || e[0] =~# '.*pwsh.exe$' 67 \ || e[0] =~# '.*pwsh$' || e[0] =~# '.*pwsh.exe$'
68 let str1 = "'cmd \"arg1\" ''arg2'' !%# \\'" 68 let str1 = "'cmd \"arg1\" ''arg2'' !%# \\'' \\! \\% \\#'"
69 let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\# \\'" 69 let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\# \\'' \\\\! \\\\% \\\\#'"
70 elseif e[0] =~# '.*fish$' || e[0] =~# '.*fish.exe$' 70 elseif e[0] =~# '.*fish$' || e[0] =~# '.*fish.exe$'
71 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%# \\\\'" 71 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%# \\\\'\\'' \\\\! \\\\% \\\\#'"
72 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\# \\\\'" 72 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\# \\\\'\\'' \\\\\\! \\\\\\% \\\\\\#'"
73 else 73 else
74 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%# \\'" 74 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%# \\'\\'' \\! \\% \\#'"
75 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\# \\'" 75 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\# \\'\\'' \\\\! \\\\% \\\\#'"
76 endif 76 endif
77 call assert_equal(str1, shellescape("cmd \"arg1\" 'arg2' !%# \\"), e[0]) 77 call assert_equal(str1, shellescape("cmd \"arg1\" 'arg2' !%# \\' \\! \\% \\#"), e[0])
78 call assert_equal(str2, shellescape("cmd \"arg1\" 'arg2' !%# \\", 1), e[0]) 78 call assert_equal(str2, shellescape("cmd \"arg1\" 'arg2' !%# \\' \\! \\% \\#", 1), e[0])
79 79
80 " Try running an external command with the shell. 80 " Try running an external command with the shell.
81 if executable(e[0]) 81 if executable(e[0])
82 " set the shell options for the current 'shell' 82 " set the shell options for the current 'shell'
83 let [&shellcmdflag, &shellpipe, &shellquote, &shellredir, 83 let [&shellcmdflag, &shellpipe, &shellquote, &shellredir,