The -g option forces variables to be created or modified at the global scope, even when declare is executed in a shell function. It is ignored in all other cases.
The following options can be used to restrict output to variables with the spec- ified attributes or to give variables attributes:
-a
Each name is an indexed array variable (see Section 6.7 [Arrays], page 89).
-A
Each name is an associative array variable (see Section 6.7 [Arrays], page 89).
-f
Use function names only.
-i
The variable is to be treated as an integer; arithmetic evaluation
(see Section 6.5 [Shell Arithmetic], page 87) is performed when the variable is assigned a value.
-l
When the variable is assigned a value, all upper-case characters are converted to lower-case. The upper-case attribute is disabled.
-n
Give each name the nameref attribute, making it a name reference to another variable. That other variable is defined by the value of name. All references and assignments to name, except for changing the -n attribute itself, are performed on the variable referenced by name’s value.
The -n attribute cannot be applied to array variables.
-r
Make names readonly. These names cannot then be assigned values by subsequent assignment statements or unset.
-t
Give each name the trace attribute. Traced functions inherit the
DEBUG and RETURN traps from the calling shell. The trace attribute has no special meaning for variables.
-u
When the variable is assigned a value, all lower-case characters are converted to upper-case. The lower-case attribute is disabled.
-x
Mark each name for export to subsequent commands via the envi- ronment.
Using ‘+’ instead of ‘-’ turns off the attribute instead, with the exceptions that
‘+a’ may not be used to destroy an array variable and ‘+r’ will not remove the readonly attribute. When used in a function, declare makes each name local, as with the local command, unless the -g option is used. If a variable name is followed by =value, the value of the variable is set to value.
When using -a or -A and the compound assignment syntax to create array variables, additional attributes do not take effect until subsequent assignments.
The return status is zero unless an invalid option is encountered, an attempt is made to define a function using ‘-f foo=bar’, an attempt is made to assign a value to a readonly variable, an attempt is made to assign a value to an array variable without using the compound assignment syntax (see Section 6.7