Mercurial > vim
annotate src/testdir/test_shell.vim @ 25048:82ae6fcd86c8 v8.2.3061
patch 8.2.3061: testing the shell option is incomplete and spread out
Commit: https://github.com/vim/vim/commit/054794c20f6322bbd9482c4124041dc0a140c78e
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Sun Jun 27 12:07:49 2021 +0200
patch 8.2.3061: testing the shell option is incomplete and spread out
Problem: Testing the shell option is incomplete and spread out.
Solution: Move shell tests to one file and increase coverage. (Yegappan
Lakshmanan, closes #8464)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 27 Jun 2021 12:15:03 +0200 |
parents | |
children | 4c366bbf6073 |
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() |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
8 " For each shell, the following options are checked: |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
9 " 'shellcmdflag', 'shellpipe', 'shellquote', 'shellredir', 'shellxescape', |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
10 " 'shellxquote' |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
11 let shells = [] |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
12 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
|
13 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
|
14 \ ['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
|
15 \ ['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
|
16 \ ['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
|
17 \ ['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
|
18 \ ['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
|
19 \ ['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
|
20 \ ['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
|
21 \ ['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
|
22 \ ['csh', '-c', '|& tee', '', '>&', '', ''], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
23 \ ['tcsh', '-c', '|& tee', '', '>&', '', '']] |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
24 endif |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
25 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
|
26 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
|
27 \ ['cmd.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
|
28 \ ['powershell.exe', '-c', '>', '', '>', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
29 \ ['powershell', '-c', '>', '', '>', '"&|<>()@^', '"'], |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
30 \ ['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
|
31 \ ['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
|
32 \ ['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
|
33 \ ['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
|
34 \ ['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
|
35 \ ['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
|
36 \ ['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
|
37 \ ['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
|
38 \ ['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
|
39 \ ['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
|
40 endif |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
41 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
42 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
|
43 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
|
44 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
|
45 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
|
46 qall! |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
47 END |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 endif |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
52 endfor |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
53 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
54 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
|
55 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
|
56 if e[0] =~# '.*csh$' || e[0] =~# '.*csh.exe$' |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
57 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' \\!%#'" |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
58 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\\\!\\%\\#'" |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
59 else |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
60 let str1 = "'cmd \"arg1\" '\\''arg2'\\'' !%#'" |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
61 let str2 = "'cmd \"arg1\" '\\''arg2'\\'' \\!\\%\\#'" |
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 call assert_equal(str1, shellescape("cmd \"arg1\" 'arg2' !%#"), e[0]) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
64 call assert_equal(str2, shellescape("cmd \"arg1\" 'arg2' !%#", 1), e[0]) |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
65 endfor |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
66 set shell& |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
67 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
|
68 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
69 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
70 " 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
|
71 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
|
72 CheckUnix |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
73 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
|
74 set shell= |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
75 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
|
76 try |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
77 shell |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
78 catch /E91:/ |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
79 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
|
80 endtry |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
81 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
|
82 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
|
83 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
84 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
85 " 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
|
86 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
|
87 CheckUnix |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
88 set shellquote=# |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
89 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
|
90 redir => v |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
91 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
|
92 redir END |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
93 set verbose& |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
94 set shellquote& |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
95 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
|
96 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
97 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
120 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
|
121 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
122 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
123 " 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
|
124 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
|
125 CheckUnix |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
126 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
127 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
|
128 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
|
129 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
|
130 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
135 set shellxquote=\\" |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
136 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
|
137 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
|
138 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
139 set shellxquote=( |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
140 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
|
141 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
|
142 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
143 set shellxquote=\\"( |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
144 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
|
145 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
|
146 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
147 set shellxescape=\"&<<()@^ |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
148 set shellxquote=( |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
149 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
|
150 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
|
151 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 endfunc |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
158 |
82ae6fcd86c8
patch 8.2.3061: testing the shell option is incomplete and spread out
Bram Moolenaar <Bram@vim.org>
parents:
diff
changeset
|
159 " vim: shiftwidth=2 sts=2 expandtab |