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