Commit df425e3
Fix
Fix the `command -v` exit status handling to account for dash being
`/bin/sh` (this is e.g. the default on Debian). Unlike bash, dash exits
with status 127 if the requested program does not exist -- and testinfra
wrongly interpreted that as `command` being unavailable.
Instead of attempting to use `command -v` and `which` in order, peform
an additional (cached) `command -v command` invocation to determine
whether `command` is available. Furthermore, assume that `command -v`
can return any non-zero status for command not existing, per POSIX.
This fixes exists() and find_command() raising an exception on systems
using dash as `/bin/sh` and lacking `which(1)`.
Fixes #668command -v compatibility with dash shell1 parent 351e8c6 commit df425e3
1 file changed
+14
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 38 | + | |
| 39 | + | |
35 | 40 | | |
36 | | - | |
| 41 | + | |
| 42 | + | |
37 | 43 | | |
38 | 44 | | |
39 | 45 | | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
43 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
44 | 53 | | |
45 | 54 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
0 commit comments