Skip to main content
Skip to main content

is

Source code

This file contains functions for checking types

Index

is::tty

Check if terminal is a tty

Example

is::tty # succeeds (returns 0)

Exit codes

  • 0: If the terminal is a tty
  • 1: If the terminal is not a tty

is::array

Check if a variable is an array

Example

local -a arr=("a" "b" "c" "d" "e")
is::array arr # succeeds (returns 0)
is::array str # fails (returns 1)

Arguments

  • $1 (string): variable name

Exit codes

  • 0: If the variable is an array
  • 1: If the variable is not an array

is::uninitialized

Check if a variable is uninitialized

Example

local -a arr=("a" "b" "c" "d" "e")
is::uninitialized arr # fails (returns 1)
local -a str
is::uninitialized str # succeeds (returns 0)

Arguments

  • $1 (string): variable name

Exit codes

  • 0: If the variable is uninitialized
  • 1: If the variable is initialized

is::set

Check if a variable is set (initialized)

Example

local -a arr=("a" "b" "c" "d" "e")
is::set arr # succeeds (returns 0)

Arguments

  • $1 (string): variable name

Exit codes

  • 0: If the variable is set
  • 1: If the variable is not set
Was this section helpful?