command -v exit code with multiple parameters

stuff-and-nonsense
2019-05-11 16:52:34 +02:00
parent cdc5988e45
commit 552971e1ca

@@ -20,6 +20,28 @@ command -v grep
None None
### Caveats:
On macOS 10.13.6, command -v appears to take multiple parameters:
```
# grep is in /usr/bin/grep
# foobar is not in path
#
$ command -v -- grep foobar; echo $?
0
```
but succeeds (with exit code 0) if *any* command exists. In the above
example, it should have failed and exited with 1 unless *all* commands
exist.
An alternative is:
$ hash <file1> <file2>
Which observes the standard behaviour of failures.
### Related resources: ### Related resources:
* [Check if a program exists from a Bash script](https://stackoverflow.com/a/677212/1899640) on StackOverflow. * [Check if a program exists from a Bash script](https://stackoverflow.com/a/677212/1899640) on StackOverflow.