annotate src/testdir/test_shell.vim @ 34159:58a6e51b437b v9.1.0040

patch 9.1.0040: issue with prompt buffer and hidden buffer Commit: https://github.com/vim/vim/commit/f267847017976ab85117bdf75b45e769836f8d69 Author: zeertzjq <zeertzjq@outlook.com> Date: Wed Jan 17 21:22:59 2024 +0100 patch 9.1.0040: issue with prompt buffer and hidden buffer Problem: Modifying a hidden buffer still interferes with prompt buffer mode changes. Solution: Save and restore b_prompt_insert. (zeertzjq) closes: #13875 Signed-off-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org> Modifying hidden buffer still interferes with prompt buffer mode changes
author Christian Brabandt <cb@256bit.org>
date Wed, 17 Jan 2024 21:30:03 +0100
parents 30ea99dff3be
children 48d01e3323ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
30626
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
100
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
101 " filter buffer contents through an external command
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
102 new
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
103 call setline(1, ['tom', 'sam', 'andy'])
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
104 try
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
105 %!sort
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
106 call assert_equal(['andy', 'sam', 'tom'], getline(1, '$'), e[0])
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
107 catch
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
108 call assert_report($'Failed to filter buffer contents, shell: {e[0]}, caught {v:exception}')
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
109 finally
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
110 bwipe!
5bc844667d46 patch 9.0.0648: when using powershell input redirection does not work
Bram Moolenaar <Bram@vim.org>
parents: 30158
diff changeset
111 endtry
25066
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
112 endif
25048
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
113 endfor
25066
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
114 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
115 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
116 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
117 endfunc
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
118
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
119 " 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
120 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
121 CheckUnix
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
122 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
123 set shell=
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
124 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
125 try
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
126 shell
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
127 catch /E91:/
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
128 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
129 endtry
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
130 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
131 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
132 endfunc
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
133
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
134 " 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
135 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
136 CheckUnix
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
137 set shellquote=#
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
138 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
139 redir => v
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
140 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
141 redir END
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
142 set verbose&
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
143 set shellquote&
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_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
145 endfunc
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
146
25066
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
147 " 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
148 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
149 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
150 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
151 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
152 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
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
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%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
156 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
157 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
158 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
159 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
160 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
161
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
170 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
171 endfunc
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
172
25068
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
173 " 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
174 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
175 CheckOption shellslash
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
176 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
177 " 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
178 " 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
179 " ".*\\\\[^\\\\]*$"
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
180 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
181 \ ['powershell', '-Command', '\\', '/'],
25084
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
182 \ ['pwsh', '-Command', '\\', '/'],
beff72446e2e patch 8.2.3079: Powershell core not supported by default
Bram Moolenaar <Bram@vim.org>
parents: 25068
diff changeset
183 \ ['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
184 \ ['sh', '-c', '/', '/']]
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
185 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
186 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
187 set noshellslash
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
188 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
189 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
190 set shellslash
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
191 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
192 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
193 endfor
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
194 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
195 endfunc
0ce24f734615 patch 8.2.3071: shell options are not set properly for PowerShell
Bram Moolenaar <Bram@vim.org>
parents: 25066
diff changeset
196
25048
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
197 " 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
198 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
199 CheckUnix
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 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
202 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
203 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
204
30769
ae10b91ac6b3 patch 9.0.0719: too many delete() calls in tests
Bram Moolenaar <Bram@vim.org>
parents: 30626
diff changeset
205 call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell', 'D')
25048
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
206 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
207 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
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 shellxquote=\\"
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
210 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
211 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
212
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
213 set shellxquote=(
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
214 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
215 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
216
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
217 set shellxquote=\\"(
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
218 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
219 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
220
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
221 set shellxescape=\"&<<()@^
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
222 set shellxquote=(
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
223 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
224 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
225
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
226 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
227 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
228 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
229 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
230 endfunc
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
231
25066
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
232 " 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
233 func Test_set_shell()
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
234 let after =<< trim [CODE]
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
235 call writefile([&shell], "Xtestout")
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
236 quit!
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
237 [CODE]
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
238
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
239 if has('win32')
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
240 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
241 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
242 else
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
243 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
244 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
245 endif
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
246
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
247 if RunVimPiped([], after, '', '')
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
248 let lines = readfile('Xtestout')
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
249 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
250 endif
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
251 call delete('Xtestout')
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
252 endfunc
4c366bbf6073 patch 8.2.3070: not enough testing for shell use
Bram Moolenaar <Bram@vim.org>
parents: 25048
diff changeset
253
30898
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
254 func Test_shell_repeat()
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
255 CheckUnix
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
256
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
257 let save_shell = &shell
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
258
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
259 call writefile(['#!/bin/sh', 'echo "Cmd: [$*]" > Xlog'], 'Xtestshell', 'D')
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
260 call setfperm('Xtestshell', "r-x------")
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
261 set shell=./Xtestshell
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
262 defer delete('Xlog')
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
263
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
264 call feedkeys(":!echo coconut\<CR>", 'xt') " Run command
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
265 call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
266
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
267 call feedkeys(":!!\<CR>", 'xt') " Re-run previous
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
268 call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
269
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
270 call writefile(['empty'], 'Xlog')
30961
22264b648b5d patch 9.0.0815
Bram Moolenaar <Bram@vim.org>
parents: 30898
diff changeset
271 call feedkeys(":!\<CR>", 'xt') " :!
22264b648b5d patch 9.0.0815
Bram Moolenaar <Bram@vim.org>
parents: 30898
diff changeset
272 call assert_equal(['Cmd: [-c ]'], readfile('Xlog'))
30898
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
273
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
274 call feedkeys(":!!\<CR>", 'xt') " :! doesn't clear previous command
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
275 call assert_equal(['Cmd: [-c echo coconut]'], readfile('Xlog'))
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
276
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
277 call feedkeys(":!echo banana\<CR>", 'xt') " Make sure setting previous command keeps working after a :! no-op
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
278 call assert_equal(['Cmd: [-c echo banana]'], readfile('Xlog'))
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
279 call feedkeys(":!!\<CR>", 'xt')
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
280 call assert_equal(['Cmd: [-c echo banana]'], readfile('Xlog'))
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
281
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
282 let &shell = save_shell
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
283 endfunc
2ee5b79038f0 patch 9.0.0783: ":!" doesn't do anything but does update the previous command
Bram Moolenaar <Bram@vim.org>
parents: 30769
diff changeset
284
31059
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
285 func Test_shell_no_prevcmd()
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
286 " this doesn't do anything, just check it doesn't crash
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
287 let after =<< trim END
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
288 exe "normal !!\<CR>"
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
289 call writefile([v:errmsg, 'done'], 'Xtestdone')
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
290 qall!
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
291 END
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
292 if RunVim([], after, '--clean')
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
293 call assert_equal(['E34: No previous command', 'done'], readfile('Xtestdone'))
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
294 endif
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
295 call delete('Xtestdone')
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
296 endfunc
30ea99dff3be patch 9.0.0864: crash when using "!!" without a previous shell command
Bram Moolenaar <Bram@vim.org>
parents: 30961
diff changeset
297
25048
82ae6fcd86c8 patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
298 " vim: shiftwidth=2 sts=2 expandtab