mirror of
https://github.com/natelandau/shell-scripting-templates.git
synced 2025-11-10 14:13:45 -05:00
rename binaryExists to commandExists
This commit is contained in:
@@ -176,7 +176,7 @@ Utility functions for working with arrays.
|
||||
|
||||
Functions for validating common use-cases
|
||||
|
||||
- **`_binaryExists_`** Check if a binary exists in the PATH
|
||||
- **`_commandExists_`** Check if a command or binary exists in the PATH
|
||||
- **`_functionExists_`** Tests if a function is available in current scope
|
||||
- **`_isInternetAvailable_`** Checks if Internet connections are possible
|
||||
- **`_isAlpha_`** Validate that a given variable contains only alphabetic characters
|
||||
|
||||
@@ -86,13 +86,13 @@ teardown() {
|
||||
assert_failure
|
||||
}
|
||||
|
||||
@test "_binaryExists_: true" {
|
||||
run _binaryExists_ "vi"
|
||||
@test "_commandExists_: true" {
|
||||
run _commandExists_ "vi"
|
||||
assert_success
|
||||
}
|
||||
|
||||
@test "_binaryExists_: false" {
|
||||
run _binaryExists_ "someNonexistantBinary"
|
||||
@test "_commandExists_: false" {
|
||||
run _commandExists_ "someNonexistantBinary"
|
||||
assert_failure
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Functions for validating common use-cases
|
||||
|
||||
_binaryExists_() {
|
||||
_commandExists_() {
|
||||
# DESC:
|
||||
# Check if a binary exists in the search PATH
|
||||
# ARGS:
|
||||
@@ -9,7 +9,7 @@ _binaryExists_() {
|
||||
# 0 if true
|
||||
# 1 if false
|
||||
# USAGE:
|
||||
# (_binaryExists_ ffmpeg ) && [SUCCESS] || [FAILURE]
|
||||
# (_commandExists_ ffmpeg ) && [SUCCESS] || [FAILURE]
|
||||
[[ $# == 0 ]] && fatal "Missing required argument to ${FUNCNAME[0]}"
|
||||
|
||||
if ! command -v "$1" >/dev/null 2>&1; then
|
||||
|
||||
Reference in New Issue
Block a user