Variable

Functions for handling variables.

Table of Contents


variable::is_array()

Check if given variable is array. Pass the variable name instead of value of the variable.

Arguments

  • $1 (string): name of the variable to check.

Exit codes

  • 0: If input is array.
  • 1: If input is not an array.

Example

arr=("a" "b" "c")
variable::is_array "arr"
#Output
0

variable::is_numeric()

Check if given variable is a number.

Arguments

  • $1 (mixed): Value of variable to check.

Exit codes

  • 0: If input is number.
  • 1: If input is not a number.

Example

variable::is_numeric "1234"
#Output
0

variable::is_int()

Check if given variable is an integer.

Arguments

  • $1 (mixed): Value of variable to check.

Exit codes

  • 0: If input is an integer.
  • 1: If input is not an integer.

Example

variable::is_int "+1234"
#Output
0

variable::is_float()

Check if given variable is a float.

Arguments

  • $1 (mixed): Value of variable to check.

Exit codes

  • 0: If input is a float.
  • 1: If input is not a float.

Example

variable::is_float "+1234.0"
#Output
0

variable::is_bool()

Check if given variable is a boolean.

Arguments

  • $1 (mixed): Value of variable to check.

Exit codes

  • 0: If input is a boolean.
  • 1: If input is not a boolean.

Example

variable::is_bool "true"
#Output
0

variable::is_true()

Check if given variable is a true.

Arguments

  • $1 (mixed): Value of variable to check.

Exit codes

  • 0: If input is true.
  • 1: If input is not true.

Example

variable::is_true "true"
#Output
0

variable::is_false()

Check if given variable is false.

Arguments

  • $1 (mixed): Value of variable to check.

Exit codes

  • 0: If input is false.
  • 1: If input is not false.

Example

variable::is_false "false"
#Output
0

variable::is_empty_or_null()

Check if given variable is empty or null.

Arguments

  • $1 (mixed): Value of variable to check.

Exit codes

  • 0: If input is empty or null.
  • 1: If input is not empty or null.

Example

test=''
variable::is_empty_or_null $test
#Output
0