DECLARE(1)

NAME

declare - declare variables and indexed arrays with attributes.

SYNOPSIS

declare [-agirx] [name[=value] ...]
declare -p [name ...]

DESCRIPTION

declare is a Bash-compatible builtin available in Rush's default mode. It creates variables or indexed arrays and applies attributes. Inside a function, declarations are local to that invocation unless -g is used. With no operands, it prints all declarations.

Assignment values use assignment-word expansion. Integer variables evaluate later assignments as arithmetic expressions. Array assignments accept Bash-style indexed values such as declare -a values=([2]=two [4]=four).

OPTIONS

-a
Declare an indexed array.
-g
Use global scope when called from a function.
-i
Apply the integer attribute and evaluate assignment values arithmetically.
-p
Print reusable declarations, optionally restricted to the named variables.
-r
Apply the readonly attribute.
-x
Apply the export attribute.
--
End option parsing.

EXIT STATUS

Zero on success, one for invalid identifiers, missing names requested with -p, or readonly assignment failures, and two for invalid options.

SEE ALSO

rush-builtins(7), typeset(1), local(1), export(1), readonly(1).