typeset [ {+|-}AEFHLRUZafghilprtuxm [n]] [ name[=value] ... ]
or
typeset -T [ {+|-}LRUZrux ] SCALAR[=value] array [ sep ]
Set or display attributes and values for shell parameters.
A parameter is created for each name
that does not already refer to one. When inside a function, a new parameter is created for every name
(even those that already exist), and is unset again when the function completes. The same rules apply to special shell parameters, which retain their special attributes when made local.
For each name=value
assignment, the parameter name
is set to value. Note that arrays currently cannot be assigned in typeset expressions, only scalars and integers.
If the shell option TYPESET_SILENT
is not set, for each remaining name
that refers to a parameter that is set, the name and value of the parameter are printed in the form of an assignment. Nothing is printed for newly-created parameters, or when any attribute flags listed below are given along with the name
. Using +
instead of -
to introduce an attribute turns it off.
Option | Description |
---|---|
| The parameters and values are printed in the form of a typeset comand and an assignment (which will be printed separately for arrays and associative arrays), regardless of other flags and options. |
| Flag on parameters is respected; no value will be shown for these parameters. |
| Two or three arguments must be present (an exception is that zero arguments are allowed to show the list of parameters created in this fashion). The first two are the name of a There is no way of untying the variables without unsetting them, or converting the type of one of them with another typeset command; |
The -g
(global flag) is treated specially: it means that any resulting parameter will not be restricted to local scope. Note that this does not necessarily mean that the parameter will be global, as the flag will apply to any existing parameter (even if unset) from an enclosing function. This flag does not affect the parameter after creation, hence it has no effect when listing existing parameters, nor does the flag +g
have any effect except in combination with -m
.
If no name
is present, the names and values of all parameters are printed. In this case the attribute flags restrict the display to only those parameters that have the specified attributes, and using +
rather than -
to introduce the flag suppresses printing of the values of parameters when there is no parameter name. Also, if the last option is the word +
, then names are printed but values are not.
If the -m
flag is given the name
arguments are taken as patterns (which should be quoted). With no attribute flags, all parameters (or functions with the -f
flag) with matching names are printed (the shell option TYPESET_SILENT
is not used in this case). Note that -m
is ignored if no patterns are given. If the +g
flag is combined with -m
, a new local parameter is created for every matching parameter that is not already local. Otherwise -m
applies all other flags or assignments to the existing parameters. Except when assignments are made with name=value
, using +m
forces the matching parameters to be printed, even inside a function.
If no attribute flags are given and either no -m
flag is present or the +m
form was used, each parameter name
printed is preceded by a list of the attributes of that parameter (array, association, exported, integer, readonly). If +m
is used with attribute flags, and all those flags are introduced with +
, the matching parameter names are printed but their values are not.
The following options can be specified:
Option | Description |
---|---|
| The names refer to associative array parameters. |
| Left justify and remove leading blanks from value. If |
| Right justify and fill with leading blanks. If |
| For arrays (but not for associative arrays), keep only the first occurrence of each duplicated value. This may also be set for colon-separated special parameters like |
| Right justify and fill with leading zeros if the first non-blank character is a digit and the |
| The names refer to array parameters. An array parameter may be created this way, but it may not be assigned to in the typeset statement. When displaying, both normal and associative arrays are shown. |
| The names refer to functions rather than parameters. No assignments can be made, and the only other valid flags are |
| Hide: only useful for special parameters (those marked |
| Hide value: specifies that typeset will not display the value of the parameter when listing parameters; the display for such parameters is always as if the |
| Use an internal integer representation. If |
| Use an internal double-precision floating point representation. On output the variable will be converted to scientific notation. If |
| Use an internal double-precision floating point representation. On output the variable will be converted to fixed-point decimal notation. If |
| Convert the result to lower case whenever the parameter is expanded. The value is not converted when assigned. |
| The given names are marked readonly. Note that if name is a special parameter, the readonly attribute can be turned on, but cannot then be turned off. |
| Tags the named parameters. Tags have no special meaning to the shell. This flag has a different meaning when used with |
| Convert the result to upper case whenever the parameter is expanded. The value is not converted when assigned. This flag has a different meaning when used with |
| Mark for automatic export to the environment of subsequently executed commands. If the option |