-
Notifications
You must be signed in to change notification settings - Fork 409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use portable "command -v" to detect installed programs #765
Conversation
The "which" utility is not guaranteed to be installed either, and if it is, its behavior is not portable either. Conversely, the "command -v" shell builtin is required to exist in all POSIX 2008 compliant shells, and is thus guaranteed to work everywhere. Examples of open-source shells likely to be installed as /bin/sh on Linux, which implement the 11-year-old standard: ash, bash, busybox, dash, ksh, mksh and zsh. See: https://mywiki.wooledge.org/BashFAQ/081 https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then/85250#85250
Note: I haven't the foggiest clue why this is executing a system() command line in a shell. Does ruby not have a standard library implementation of e.g. python's |
This will simply think nothing ever exists by default, since "which" doesn't exist, but for extra bonus breakage if you do have a version of
|
None |
UaezapHKqfZ_ACyu6WOU1Q |
💯 |
Commit |
The "which" utility is not guaranteed to be installed either, and if it is, its behavior is not portable either.
Conversely, the "command -v" shell builtin is required to exist in all POSIX 2008 compliant shells, and is thus guaranteed to work everywhere.
Examples of open-source shells likely to be installed as /bin/sh on Linux, which implement the 11-year-old standard: ash, bash, busybox, dash, ksh, mksh and zsh.
See:
https://mywiki.wooledge.org/BashFAQ/081
https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then/85250#85250