readonly(1) readonly(1)
NAME
readonly - protect shell variables
SYNOPSIS
readonly[ name]...
DESCRIPTION
The shell built-in readonly marks the specified shell variables as
read-only, i.e. protects them from being changed by reassignment in
the current shell. An error message is issued if any such attempt is
subsequently made.
This protection only applies to the current shell. This means that the
variable may be reassigned in a subshell or in a parent shell (i.e.
when you terminate the current shell). Within the current shell, how-
ever, it is not possible to undo this protection.
If you invoke readonly without arguments, a list of all existing
read-only variables in the current shell is written to standard out-
put.
OPERANDS
The Korn shell ksh supports additional options, and a value can be
assigned to the readonly variables [see ksh(1)].
name Name of the shell variable to be marked as read-only (i.e. pro-
tected). You have to assign a value to this variable before you
call readonly.
You can list any number of shell variables, separated by commas.
name not specified:
All shell variables protected in the current shell are written
on the standard output in the following format:
readonly name
or for the Korn shell ksh:
name = value
or, if the -p option is set:
readonly name = value
ERROR MESSAGE
name: is read only
This error message is issued when you try to assign a value to a pro-
tected shell variable.
Page 1 Reliant UNIX 5.44 Printed 11/98
readonly(1) readonly(1)
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed. If LCMESSAGES is undefined or is defined
as the null string, it defaults to the value of LANG. If LANG is like-
wise undefined or null, the system acts as if it were not internation-
alized.
The LCALL environment variable governs the entire locale. LCALL
takes precedence over all the other environment variables which affect
internationalization.
EXAMPLES
Marking the shell variable HOME as read-only in the current shell:
$ readonly HOME
$ readonly
readonly HOME
$ sh
$ readonly
$ CTRL-D
$ readonly
readonly HOME
The HOME variable is not protected in the subshell.
NOTES
Some differences in behavior may occur when using readonly, depending
on which shell is being used. The possible differences are not
described specifically.
SEE ALSO
ksh(1), sh(1).
Page 2 Reliant UNIX 5.44 Printed 11/98