Mercurial > vim
annotate src/testdir/test_shell.vim @ 30262:2dd1fb31cb87
Added tag v9.0.0466 for changeset 6b658ef69e9348c4b145bde0be4400255703c647
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 14 Sep 2022 23:15:03 +0200 |
parents | 008808e60963 |
children | 5bc844667d46 |
rev | line source |
---|---|
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
1 " Test for the shell related options ('shell', 'shellcmdflag', 'shellpipe', |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
2 " 'shellquote', 'shellredir', 'shellxescape', and 'shellxquote') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
3 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
4 source check.vim |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
5 source shared.vim |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
6 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
7 func Test_shell_options() |
30158
008808e60963
patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents:
25715
diff
changeset
|
8 if has('win32') |
008808e60963
patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents:
25715
diff
changeset
|
9 " FIXME: This test is flaky on MS-Windows. |
008808e60963
patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents:
25715
diff
changeset
|
10 let g:test_is_flaky = 1 |
008808e60963
patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents:
25715
diff
changeset
|
11 endif |
008808e60963
patch 9.0.0415: on MS-Windows some tests are flaky
Bram Moolenaar <Bram@vim.org>
parents:
25715
diff
changeset
|
12 |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
13 " The expected value of 'shellcmdflag', 'shellpipe', 'shellquote', |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
14 " 'shellredir', 'shellxescape', 'shellxquote' for the supported shells. |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
15 let shells = [] |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
16 if has('unix') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
17 let shells += [['sh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
18 \ ['ksh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
19 \ ['mksh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
20 \ ['zsh', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
21 \ ['zsh-beta', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
22 \ ['bash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 \ ['fish', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 \ ['ash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 \ ['dash', '-c', '2>&1| tee', '', '>%s 2>&1', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
26 \ ['csh', '-c', '|& tee', '', '>&', '', ''], |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
27 \ ['tcsh', '-c', '|& tee', '', '>&', '', ''], |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
28 \ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '', '']] |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 endif |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 if has('win32') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
31 let shells += [['cmd', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
32 \ ['cmd.exe', '/c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '('], |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
33 \ ['powershell.exe', '-Command', '2>&1 | Out-File -Encoding default', |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
34 \ '', '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
35 \ ['powershell', '-Command', '2>&1 | Out-File -Encoding default', '', |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
36 \ '2>&1 | Out-File -Encoding default', '"&|<>()@^', '"'], |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
37 \ ['pwsh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
38 \ ['pwsh', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
39 \ ['sh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
40 \ ['ksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 \ ['mksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 \ ['pdksh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
43 \ ['zsh.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
44 \ ['zsh-beta.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
45 \ ['bash.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
46 \ ['dash.exe', '-c', '>%s 2>&1', '', '>%s 2>&1', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 \ ['csh.exe', '-c', '>&', '', '>&', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 \ ['tcsh.exe', '-c', '>&', '', '>&', '"&|<>()@^', '"']] |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
49 endif |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
50 |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
51 " start a new Vim instance with 'shell' set to each of the supported shells |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
52 " and check the default shell option settings |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 let after =<< trim END |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 let l = [&shell, &shellcmdflag, &shellpipe, &shellquote] |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
55 let l += [&shellredir, &shellxescape, &shellxquote] |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
56 call writefile([json_encode(l)], 'Xtestout') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 qall! |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 END |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 for e in shells |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 if RunVim([], after, '--cmd "set shell=' .. e[0] .. '"') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 call assert_equal(e, json_decode(readfile('Xtestout')[0])) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
62 endif |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
63 endfor |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
65 " Test shellescape() for each of the shells. |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 for e in shells |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 exe 'set shell=' .. e[0] |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
68 if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$' |
25715
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
69 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%# \\'\\'' \\\\! \\% \\#'" |
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
70 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\# \\'\\'' \\\\\\! \\\\% \\\\#'" |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
71 elseif e[0] =~# '.*powershell$' || e[0] =~# '.*powershell.exe$' |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
72 \ || e[0] =~# '.*pwsh$' || e[0] =~# '.*pwsh.exe$' |
25715
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
73 let str1 = "'cmd \"arg1\" ''arg2'' !%# \\'' \\! \\% \\#'" |
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
74 let str2 = "'cmd \"arg1\" ''arg2'' \\!\\%\\# \\'' \\\\! \\\\% \\\\#'" |
25698
000b37efd5fa
patch 8.2.3385: escaping for fish shell does not work properly
Bram Moolenaar <Bram@vim.org>
parents:
25527
diff
changeset
|
75 elseif e[0] =~# '.*fish$' || e[0] =~# '.*fish.exe$' |
25715
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
76 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%# \\\\'\\'' \\\\! \\\\% \\\\#'" |
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
77 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\# \\\\'\\'' \\\\\\! \\\\\\% \\\\\\#'" |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 else |
25715
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
79 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%# \\'\\'' \\! \\% \\#'" |
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
80 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\# \\'\\'' \\\\! \\\\% \\\\#'" |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 endif |
25715
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
82 call assert_equal(str1, shellescape("cmd \"arg1\" 'arg2' !%# \\' \\! \\% \\#"), e[0]) |
454cbc872368
patch 8.2.3393: escaping for fish shell is skipping some characters
Bram Moolenaar <Bram@vim.org>
parents:
25698
diff
changeset
|
83 call assert_equal(str2, shellescape("cmd \"arg1\" 'arg2' !%# \\' \\! \\% \\#", 1), e[0]) |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
84 |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
85 " Try running an external command with the shell. |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
86 if executable(e[0]) |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
87 " set the shell options for the current 'shell' |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
88 let [&shellcmdflag, &shellpipe, &shellquote, &shellredir, |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
89 \ &shellxescape, &shellxquote] = e[1:6] |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
90 new |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
91 try |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
92 r !echo hello |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
93 call assert_equal('hello', substitute(getline(2), '\W', '', 'g'), e[0]) |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
94 catch |
25527
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
95 call assert_report('Failed to run shell command, shell: ' .. e[0] |
d5e9c05b4811
patch 8.2.3300: Lua: can only execute on Vim command at a time
Bram Moolenaar <Bram@vim.org>
parents:
25084
diff
changeset
|
96 \ .. ', caught ' .. v:exception) |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
97 finally |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
98 bwipe! |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
99 endtry |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
100 endif |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
101 endfor |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
102 set shell& shellcmdflag& shellpipe& shellquote& |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
103 set shellredir& shellxescape& shellxquote& |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
104 call delete('Xtestout') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
106 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
107 " Test for the 'shell' option |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
108 func Test_shell() |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
109 CheckUnix |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
110 let save_shell = &shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
111 set shell= |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 let caught_e91 = 0 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
113 try |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
114 shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
115 catch /E91:/ |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
116 let caught_e91 = 1 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
117 endtry |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
118 call assert_equal(1, caught_e91) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
119 let &shell = save_shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
121 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 " Test for the 'shellquote' option |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 func Test_shellquote() |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
124 CheckUnix |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
125 set shellquote=# |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 set verbose=20 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 redir => v |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
128 silent! !echo Hello |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
129 redir END |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
130 set verbose& |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 set shellquote& |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
132 call assert_match(': "#echo Hello#"', v) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
133 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
134 |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
135 " Test for the 'shellescape' option |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 func Test_shellescape() |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
137 let save_shell = &shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
138 set shell=bash |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 call assert_equal("'text'", shellescape('text')) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 call assert_equal("'te\"xt'", 'te"xt'->shellescape()) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
141 call assert_equal("'te'\\''xt'", shellescape("te'xt")) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
142 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 call assert_equal("'te%xt'", shellescape("te%xt")) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 call assert_equal("'te\\%xt'", shellescape("te%xt", 1)) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
145 call assert_equal("'te#xt'", shellescape("te#xt")) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
146 call assert_equal("'te\\#xt'", shellescape("te#xt", 1)) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 call assert_equal("'te!xt'", shellescape("te!xt")) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 call assert_equal("'te\\!xt'", shellescape("te!xt", 1)) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
150 call assert_equal("'te\nxt'", shellescape("te\nxt")) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
151 call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1)) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 set shell=tcsh |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
153 call assert_equal("'te\\!xt'", shellescape("te!xt")) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
154 call assert_equal("'te\\\\!xt'", shellescape("te!xt", 1)) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
155 call assert_equal("'te\\\nxt'", shellescape("te\nxt")) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
156 call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1)) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
157 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 let &shell = save_shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
160 |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
161 " Test for 'shellslash' |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
162 func Test_shellslash() |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
163 CheckOption shellslash |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
164 let save_shellslash = &shellslash |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
165 " The shell and cmdflag, and expected slash in tempname with shellslash set or |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
166 " unset. The assert checks the file separator before the leafname. |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
167 " ".*\\\\[^\\\\]*$" |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
168 let shells = [['cmd', '/c', '\\', '/'], |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
169 \ ['powershell', '-Command', '\\', '/'], |
25084
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
170 \ ['pwsh', '-Command', '\\', '/'], |
beff72446e2e
patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents:
25068
diff
changeset
|
171 \ ['pwsh', '-c', '\\', '/'], |
25068
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
172 \ ['sh', '-c', '/', '/']] |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
173 for e in shells |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
174 exe 'set shell=' .. e[0] .. ' | set shellcmdflag=' .. e[1] |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
175 set noshellslash |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
176 let file = tempname() |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
177 call assert_match('^.\+' .. e[2] .. '[^' .. e[2] .. ']\+$', file, e[0] .. ' ' .. e[1] .. ' nossl') |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
178 set shellslash |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
179 let file = tempname() |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
180 call assert_match('^.\+' .. e[3] .. '[^' .. e[3] .. ']\+$', file, e[0] .. ' ' .. e[1] .. ' ssl') |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
181 endfor |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
182 let &shellslash = save_shellslash |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
183 endfunc |
0ce24f734615
patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents:
25066
diff
changeset
|
184 |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
185 " Test for 'shellxquote' |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
186 func Test_shellxquote() |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
187 CheckUnix |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
188 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
189 let save_shell = &shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
190 let save_sxq = &shellxquote |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
191 let save_sxe = &shellxescape |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
192 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
193 call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
194 call setfperm('Xtestshell', "r-x------") |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
195 set shell=./Xtestshell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
196 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
197 set shellxquote=\\" |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
198 call feedkeys(":!pwd\<CR>\<CR>", 'xt') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
199 call assert_equal(['Cmd: [-c "pwd"]'], readfile('Xlog')) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
200 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
201 set shellxquote=( |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
202 call feedkeys(":!pwd\<CR>\<CR>", 'xt') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
203 call assert_equal(['Cmd: [-c (pwd)]'], readfile('Xlog')) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
204 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
205 set shellxquote=\\"( |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
206 call feedkeys(":!pwd\<CR>\<CR>", 'xt') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
207 call assert_equal(['Cmd: [-c "(pwd)"]'], readfile('Xlog')) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
208 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
209 set shellxescape=\"&<<()@^ |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
210 set shellxquote=( |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
211 call feedkeys(":!pwd\"&<<{}@^\<CR>\<CR>", 'xt') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
212 call assert_equal(['Cmd: [-c (pwd^"^&^<^<{}^@^^)]'], readfile('Xlog')) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
213 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
214 let &shell = save_shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
215 let &shellxquote = save_sxq |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
216 let &shellxescape = save_sxe |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
217 call delete('Xtestshell') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
218 call delete('Xlog') |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
219 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
220 |
25066
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
221 " Test for using the shell set in the $SHELL environment variable |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
222 func Test_set_shell() |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
223 let after =<< trim [CODE] |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
224 call writefile([&shell], "Xtestout") |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
225 quit! |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
226 [CODE] |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
227 |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
228 if has('win32') |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
229 let $SHELL = 'C:\with space\cmd.exe' |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
230 let expected = '"C:\with space\cmd.exe"' |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
231 else |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
232 let $SHELL = '/bin/with space/sh' |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
233 let expected = '/bin/with\ space/sh' |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
234 endif |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
235 |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
236 if RunVimPiped([], after, '', '') |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
237 let lines = readfile('Xtestout') |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
238 call assert_equal(expected, lines[0]) |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
239 endif |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
240 call delete('Xtestout') |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
241 endfunc |
4c366bbf6073
patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents:
25048
diff
changeset
|
242 |
25048
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
243 " vim: shiftwidth=2 sts=2 expandtab |