Commit 3417298
committed
tests: Set ZSH explicitly and avoid 'env'
'env -i' clears the complete environment, including PATH. In that
case, on most platforms, when excuting commands without PATH being
set, /usr/bin and /bin are searched, e.g. on Linux:
$ strace env -i asdf |& grep asdf
execve("/usr/bin/env", ["env", "-i", "asdf"], 0x7ffc3e3c0890 /* 27 vars */) = 0
execve("/bin/asdf", ["asdf"], 0x55be2da090d0 /* 0 vars */) = -1 ENOENT (No such file or directory)
execve("/usr/bin/asdf", ["asdf"], 0x55be2da090d0 /* 0 vars */) = -1 ENOENT (No such file or directory)
write(2, "\342\200\230asdf\342\200\231", 10‘asdf’) = 10
Howver, this does not hold on every platform. E.g. on Cygwin, so
such fallback paths are searched:
$ strace env -i asdf |& grep asdf
37 25736 [main] env 3516 build_argv: argv[2] = 'asdf'
643 30373 [main] env 3516 find_exec: find_exec (asdf)
35 30408 [main] env 3516 find_exec: (null) = find_exec (asdf)
36 30444 [main] env 3516 spawnve: spawnve (, asdf, 0x10040B000)
‘asdf’ 199 53601 [main] env 3516 write: 10 = write(2, 0x10040B040, 10)
$ env -i zsh
env: ‘zsh’: No such file or directory
Therefore, avoid the need for 'env' to do the searching and invoke
the proper zsh binary explicitly.1 parent 6d5372a commit 3417298
2 files changed
+6
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
75 | | - | |
76 | | - | |
| 74 | + | |
| 75 | + | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
| |||
83 | 82 | | |
84 | 83 | | |
85 | 84 | | |
86 | | - | |
| 85 | + | |
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
| |||
283 | 282 | | |
284 | 283 | | |
285 | 284 | | |
286 | | - | |
| 285 | + | |
287 | 286 | | |
288 | 287 | | |
289 | 288 | | |
| |||
0 commit comments