Skip to content

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.

Location: bin/build/tools/text.sh

Arguments

  • element - EmptyString. Thing to search for
  • arrayElement0 ... - 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 array
  • 1 - 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)

Location: bin/build/tools/type.sh

Arguments

  • value - EmptyString. Required. Value to test.

Return codes

  • 0 - if it is a number equal to or greater than zero
  • 1 - 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)

Location: bin/build/tools/type.sh

Arguments

  • value - EmptyString. Required. Value to test.

Return codes

  • 0 - if it is a floating point number
  • 1 - 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

Location: bin/build/tools/type.sh

Arguments

  • value - EmptyString. Required. Value to test.
  • value - EmptyString. The value to test.

Return codes

  • 0 - if it is a signed integer
  • 1 - 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.

Location: bin/build/tools/example.sh

Arguments

  • value - EmptyString. Value to test if it is an unsigned integer.

Return codes

  • 0 - if it is an unsigned integer
  • 1 - if it is not an unsigned integer

Requires

See Also

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.

Location: bin/build/tools/type.sh

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 integer
  • 1 - if it is not a positive integer

Requires

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)

Location: bin/build/tools/type.sh

Arguments

  • value - EmptyString. Required. Value to test.

Return codes

  • 0 - if it is a floating point number
  • 1 - if it is not a floating point number

Credits

Thanks to F. Hauri - Give Up GitHub (isnum_Case) .

isFunction

Is argument a bash function?

Usage

isFunction string [ --help ]

Test if arguments are bash functions. If no arguments are passed, returns exit code 1.

Location: bin/build/tools/type.sh

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 function
  • 1 - argument is not a bash function

Requires

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.

Location: bin/build/tools/type.sh

Arguments

  • string - String. Required. Path to binary to test if it is executable.

Return codes

  • 0 - All arguments are executable binaries
  • 1 - One or or more arguments are not executable binaries

Environment

Requires

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.

Location: bin/build/tools/type.sh

Arguments

  • string - EmptyString. Required. Path to binary to test if it is executable.

Return codes

  • 0 - All arguments are callable as a command
  • 1 - One or or more arguments are callable as a command

Requires

isTrue

True-ish

Usage

isTrue [ --help ] [ value ... ]

True-ish Succeeds when all arguments are "true"-ish

Location: bin/build/tools/type.sh

Arguments

  • --help - Flag. Optional. Display this help.
  • value ... - EmptyString. One or more values to test.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

isType

Bash types beyond type -t

Usage

isType

Bash types beyond type -t

Location: bin/build/tools/type.sh

Arguments

  • none

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

isArray

Is a variable declared as an array?

Usage

isArray variableName [ --help ]

Is a variable declared as an array?

Location: bin/build/tools/type.sh

Arguments

  • variableName - String. Required. Variable name to check.
  • --help - Flag. Optional. Display this help.

Return codes

  • 0 - Success
  • 1 - Environment error
  • 2 - Argument error

🛠️ Tools · ⬅ Top