Table of Contents

Bash - Declare (Variable declaration and attribute)

About

Declare variables and/or give them attributes.

Syntax

declare [-afFirtx] [-p] [name[=value] ...]
typeset [-afFirtx] [-p] [name[=value] ...]

where:

The following options can be used to restrict output to variables with the specified attribute or to give variables attributes:

Using + instead of - turns off the attribute instead, with the exception that +a may not be used to destroy an array variable.

Scope

When used in a function, makes each name local, as with the local command.

If a variable name is followed by =value, the value of the variable is set to value.

Return value

The return value is 0 unless: