typeset

Declare variables and give them attributes.

TLDR

Declare a string variable with the specified value

$ typeset [variable]="[value]"
copy


Declare an integer variable with the specified value
$ typeset -i [variable]="[value]"
copy


Declare an array variable with the specified value
$ typeset [variable]=([item_a item_b item_c])
copy


Declare an associative array variable with the specified value
$ typeset -A [variable]=([[key_a]=item_a [key_b]=item_b [key_c]=item_c])
copy


Declare a readonly variable with the specified value
$ typeset -r [variable]="[value]"
copy


Declare a global variable within a function with the specified value
$ typeset -g [variable]="[value]"
copy

Copied to clipboard