Type Functions
inArray
Check if an element exists in an array
Usage
inArray [ element ] [ arrayElement0 ... ]
Check if an element exists in an array Without arguments, displays help.
Arguments
element- EmptyString. Thing to search forarrayElement0 ...- Array. Optional. One or more array elements to match
Examples
if inArray "$thing" "${things[@]+"${things[@]}"}"; then
things+=("$thing")
fi
Return codes
0- If element is found in array1- If element is NOT found in array
isUnsignedNumber
Test if an argument is a positive floating point number
Usage
isUnsignedNumber value
Test if an argument is a positive floating point number
(1e3 notation NOT supported)
Arguments
value- EmptyString. Required. Value to test.
Return codes
0- if it is a number equal to or greater than zero1- if it is not a number equal to or greater than zero
Credits
Thanks to F. Hauri - Give Up GitHub (isnum_Case) .
isNumber
Test if an argument is a floating point number
Usage
isNumber value
Test if an argument is a floating point number
(1e3 notation NOT supported)
Arguments
value- EmptyString. Required. Value to test.
Return codes
0- if it is a floating point number1- if it is not a floating point number
Credits
Thanks to F. Hauri - Give Up GitHub (isnum_Case) .
isInteger
Test if an argument is a signed integer
Usage
isInteger value [ value ]
Test if an argument is a signed integer
Arguments
value- EmptyString. Required. Value to test.value- EmptyString. The value to test.
Return codes
0- if it is a signed integer1- if it is not a signed integer
Credits
Thanks to F. Hauri - Give Up GitHub (isuint_Case) .
isUnsignedInteger
Is value an unsigned integer?
Usage
isUnsignedInteger [ value ]
Test if a value is a 0 or greater integer. Leading "+" is ok.
Arguments
value- EmptyString. Value to test if it is an unsigned integer.
Return codes
0- if it is an unsigned integer1- if it is not an unsigned integer
Credits
Thanks to F. Hauri - Give Up GitHub (isnum_Case) .
isPositiveInteger
Test if an argument is a positive integer (non-zero)
Usage
isPositiveInteger value [ --help ]
Test if an argument is a positive integer (non-zero) Takes one argument only.
Arguments
value- EmptyString. Required. Value to check if it is an unsigned integer--help- Flag. Optional. Display this help.
Return codes
0- if it is a positive integer1- if it is not a positive integer
isNumber
Test if an argument is a floating point number
Usage
isNumber value
Test if an argument is a floating point number
(1e3 notation NOT supported)
Arguments
value- EmptyString. Required. Value to test.
Return codes
0- if it is a floating point number1- if it is not a floating point number
Credits
Thanks to F. Hauri - Give Up GitHub (isnum_Case) .
isFunction
Test if argument are bash functions
Usage
isFunction string [ --help ]
Test if argument are bash functions If no arguments are passed, returns exit code 1.
Arguments
string- String. Required. String to test if it is a bash function. Builtins are supported..is explicitly not supported to disambiguate it from the current directory..--help- Flag. Optional. Display this help.
Return codes
0- argument is bash function1- argument is not a bash function
isExecutable
Test if all arguments are executable binaries
Usage
isExecutable string
Test if all arguments are executable binaries If no arguments are passed, returns exit code 1.
Arguments
string- String. Required. Path to binary to test if it is executable.
Return codes
0- All arguments are executable binaries1- One or or more arguments are not executable binaries
Environment
- {SEE:PATH.sh}
isCallable
Test if all arguments are callable as a command
Usage
isCallable string
Test if all arguments are callable as a command If no arguments are passed, returns exit code 1.
Arguments
string- EmptyString. Required. Path to binary to test if it is executable.
Return codes
0- All arguments are callable as a command1- One or or more arguments are callable as a command
isTrue
True-ish
Usage
isTrue [ --help ] [ value ... ]
True-ish Succeeds when all arguments are "true"-ish
Arguments
--help- Flag. Optional. Display this help.value ...- EmptyString. One or more values to test.
Return codes
0- Success1- Environment error2- Argument error
isType
Bash types beyond
type -t
Usage
isType
Bash types beyond type -t
Arguments
- none
Return codes
0- Success1- Environment error2- Argument error
isArray
Is a variable declared as an array?
Usage
isArray variableName [ --help ]
Is a variable declared as an array?
Arguments
variableName- String. Required. Variable name to check.--help- Flag. Optional. Display this help.
Return codes
0- Success1- Environment error2- Argument error