Mercurial > vim
annotate src/testdir/test_windows_home.vim @ 33811:06219b3bdaf3 v9.0.2121
patch 9.0.2121: [security]: use-after-free in ex_substitute
Commit: https://github.com/vim/vim/commit/26c11c56888d01e298cd8044caf860f3c26f57bb
Author: Christian Brabandt <cb@256bit.org>
Date: Wed Nov 22 21:26:41 2023 +0100
patch 9.0.2121: [security]: use-after-free in ex_substitute
Problem: [security]: use-after-free in ex_substitute
Solution: always allocate memory
closes: #13552
A recursive :substitute command could cause a heap-use-after free in Vim
(CVE-2023-48706).
The whole reproducible test is a bit tricky, I can only reproduce this
reliably when no previous substitution command has been used yet
(which is the reason, the test needs to run as first one in the
test_substitute.vim file) and as a combination of the `:~` command
together with a :s command that contains the special substitution atom `~\=`
which will make use of a sub-replace special atom and calls a vim script
function.
There was a comment in the existing :s code, that already makes the
`sub` variable allocate memory so that a recursive :s call won't be able
to cause any issues here, so this was known as a potential problem
already. But for the current test-case that one does not work, because
the substitution does not start with `\=` but with `~\=` (and since
there does not yet exist a previous substitution atom, Vim will simply
increment the `sub` pointer (which then was not allocated dynamically)
and later one happily use a sub-replace special expression (which could
then free the `sub` var).
The following commit fixes this, by making the sub var always using
allocated memory, which also means we need to free the pointer whenever
we leave the function. Since sub is now always an allocated variable,
we also do no longer need the sub_copy variable anymore, since this one
was used to indicated when sub pointed to allocated memory (and had
therefore to be freed on exit) and when not.
Github Security Advisory:
https://github.com/vim/vim/security/advisories/GHSA-c8qm-x72m-q53q
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 22 Nov 2023 22:15:05 +0100 |
parents | 08940efa6b4e |
children |
rev | line source |
---|---|
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Test for $HOME on Windows. |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 |
17663
403ac78df9a0
patch 8.1.1829: difference in screenshots
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
3 source check.vim |
403ac78df9a0
patch 8.1.1829: difference in screenshots
Bram Moolenaar <Bram@vim.org>
parents:
17089
diff
changeset
|
4 CheckMSWindows |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 let s:env = {} |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 func s:restore_env() |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 for i in keys(s:env) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 exe 'let ' . i . '=s:env["' . i . '"]' |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 endfor |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endfunc |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 func s:save_env(...) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 for i in a:000 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 exe 'let s:env["' . i . '"]=' . i |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 endfor |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 endfunc |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 func s:unlet_env(...) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 for i in a:000 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 exe 'let ' . i . '=""' |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 endfor |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 endfunc |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 func CheckHomeIsMissingFromSubprocessEnvironment() |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 silent! let out = system('set') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 let env = filter(split(out, "\n"), 'v:val=~"^HOME="') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 call assert_equal(0, len(env)) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 endfunc |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 func CheckHomeIsInSubprocessEnvironment(exp) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 silent! let out = system('set') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 let env = filter(split(out, "\n"), 'v:val=~"^HOME="') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 let home = len(env) == 0 ? "" : substitute(env[0], '[^=]\+=', '', '') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 call assert_equal(a:exp, home) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 endfunc |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 func CheckHome(exp, ...) |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
40 call assert_equal(a:exp, $HOME) |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
41 call assert_equal(a:exp, expand('~', ':p')) |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 if !a:0 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 call CheckHomeIsMissingFromSubprocessEnvironment() |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 else |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
45 call CheckHomeIsInSubprocessEnvironment(a:1) |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 endif |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 endfunc |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
49 func Test_WindowsHome() |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 command! -nargs=* SaveEnv call <SID>save_env(<f-args>) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 command! -nargs=* RestoreEnv call <SID>restore_env() |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 command! -nargs=* UnletEnv call <SID>unlet_env(<f-args>) |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
53 set noshellslash |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
55 let save_home = $HOME |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
56 SaveEnv $USERPROFILE $HOMEDRIVE $HOMEPATH |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 try |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
58 " Normal behavior: use $HOMEDRIVE and $HOMEPATH, ignore $USERPROFILE |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
59 let $USERPROFILE = 'unused' |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 let $HOMEDRIVE = 'C:' |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 let $HOMEPATH = '\foobar' |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
62 let $HOME = '' " Force recomputing "homedir" |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 call CheckHome('C:\foobar') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
65 " Same, but with $HOMEPATH not set |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
66 UnletEnv $HOMEPATH |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
67 let $HOME = '' " Force recomputing "homedir" |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
68 call CheckHome('C:\') |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
70 " Use $USERPROFILE if $HOMEPATH and $HOMEDRIVE are empty |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
71 UnletEnv $HOMEDRIVE $HOMEPATH |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 let $USERPROFILE = 'C:\foo' |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
73 let $HOME = '' " Force recomputing "homedir" |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
74 call CheckHome('C:\foo') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
76 " If $HOME is set the others don't matter |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 let $HOME = 'C:\bar' |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
78 let $USERPROFILE = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
79 let $HOMEDRIVE = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
80 let $HOMEPATH = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
81 call CheckHome('C:\bar', 'C:\bar') |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
83 " If $HOME contains %USERPROFILE% it is expanded |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 let $USERPROFILE = 'C:\foo' |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
85 let $HOME = '%USERPROFILE%\bar' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
86 let $HOMEDRIVE = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
87 let $HOMEPATH = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
88 call CheckHome('C:\foo\bar', '%USERPROFILE%\bar') |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
90 " Invalid $HOME is kept |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
91 let $USERPROFILE = 'C:\foo' |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
92 let $HOME = '%USERPROFILE' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
93 let $HOMEDRIVE = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
94 let $HOMEPATH = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
95 call CheckHome('%USERPROFILE', '%USERPROFILE') |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
97 " %USERPROFILE% not at start of $HOME is not expanded |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
98 let $USERPROFILE = 'unused' |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 let $HOME = 'C:\%USERPROFILE%' |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
100 let $HOMEDRIVE = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
101 let $HOMEPATH = 'unused' |
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
102 call CheckHome('C:\%USERPROFILE%', 'C:\%USERPROFILE%') |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 if has('channel') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 RestoreEnv |
12275
67bc88591ede
patch 8.0.1017: test for MS-Windows $HOME always passes
Christian Brabandt <cb@256bit.org>
parents:
12265
diff
changeset
|
106 let $HOME = save_home |
12265
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 let env = '' |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 let job = job_start('cmd /c set', {'out_cb': {ch,x->[env,execute('let env=x')]}}) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 sleep 1 |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 let env = filter(split(env, "\n"), 'v:val=="HOME"') |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
111 let home = len(env) == 0 ? "" : env[0] |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
112 call assert_equal('', home) |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
113 endif |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 finally |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 RestoreEnv |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 delcommand SaveEnv |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 delcommand RestoreEnv |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 delcommand UnletEnv |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
119 endtry |
03e4be2e3d53
patch 8.0.1012: MS-Windows: problem with $HOME when is was set internally
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
120 endfunc |
21765
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
17663
diff
changeset
|
121 |
08940efa6b4e
patch 8.2.1432: various inconsistencies in test files
Bram Moolenaar <Bram@vim.org>
parents:
17663
diff
changeset
|
122 " vim: shiftwidth=2 sts=2 expandtab |