typeset

assign attributes and values to KornShell variables

KornShell Built-in


SYNOPSIS

typeset ±f[tux] name name...

typeset [-I] [±lprtuxH] [±iLRZ[number]] [variable[=value] ...]


DESCRIPTION

Invoking typeset with no options displays a list of all KornShell variables and their attributes. This list is sorted by variable name and includes quoting so that it can be re-input to the KornShell with the built-in command eval. When only arguments of the form +option are specified, typeset displays a list of the variables which have all specified attributes set. When only arguments of the form -option are present, typeset displays a list of all the variables having all the specified attributes set, and also displays their values.

When the -f option is used, typeset applies to KornShell functions; otherwise, it applies to variables. For functions, the only other applicable options are -t, -u and -x.

If the command line contains at least one variable, the attributes of each specified variable are changed. In this case, parameters of the form -option turn on the associated attributes. Parameters of the form +option turn off the associated attributes. Parameters of the form variable=value turn on the associated attributes and also assign value to variable.

When typeset is invoked inside a function, a new instance of each variable is created. After the function terminates, each variable is restored to the value and attributes it had before the function was called.

Options

-H

performs POSIX to host-name file mapping.

-i[number]

marks each variable as an integer value, making arithmetic faster. If number is given and non-zero, the output base of each variable is number.

-I

handles variable in a case-insensitive manner. With this option, Var , var, and VAR all refer to the same variable. If two or more variables exist which, when the command is issued, have the same name as variable, typeset issues an error message.

-l

converts uppercase characters to lowercase in any value assigned to a variable. If the -u option is currently turned on, this option turns it off.

-p

writes output to the co-process.

-r

makes each variable read-only. See readonly.

-t

tags each variable. Tags are user-defined and have no meaning to the shell. For functions (with the -f option), this turns on the xtrace option. See set for a discussion of the xtrace option.

-u

converts lowercase characters to uppercase in any value assigned to a variable. If the -l option is currently turned on, this option turns it off.

When used with -f, -u indicates that the functions named in the command line are not yet defined. The attributes specified by the typeset command are applied to the functions once they are defined.

-x

sets each variable for automatic export. See export.

The following three options justify, within a field, the values assigned to each variable. The width of the field is number if it is defined and non-zero; otherwise, the width is that of the first assignment made to variable.
-L[number]

left justifies the values assigned to each variable by first removing any leading blanks. Leading zeroes are also removed if the -Z option has been turned on. Blanks are added on the end or the end of the value is truncated as necessary. If the -R option is currently turned on, this option turns it off.

-R[number]

right justifies the values assigned to each variable by adding leading blanks or by truncating the start of the value as necessary. If the -L option is currently turned on, this option turns it off.

-Z[number]

right justifies values assigned to each variable. If the first non-blank character of value is a digit, leading zeroes are used. See also the -L option.


DIAGNOSTICS

Possible exit status values are:
0

Successful completion.

>0

The number of invalid names specified on the command line.

Base number not in [2,36]

You used the -i option to specify a base for an integer, but the base was not in the range 2 through 36. All bases must be in this range.

name: Not a function

The given name is not defined as a function.


PORTABILITY

typeset is a built-in command of the KornShell on UNIX systems, but is not a Bourne Shell command.
It is an extension to the POSIX.2 and XPG standards.


NOTE

This is a special built-in command of the MKS KornShell.


SEE ALSO

Commands:
export, integer, readonly, sh


Updated MKS Toolkit [3khat16.ico]HP3000 [3khat16.ico]3kMail [archive16.gif]