READONLY(1) General Commands Manual READONLY(1)

readonlyset read-only attribute for variables 1

readonly name[=word]. . .

readonly -p The variables whose names are specified shall be given the readonly attribute. The values of variables with the read-only attribute cannot be changed by subsequent assignment, nor can those variables be unset by the unset utility. When −p is specified, readonly shall write to the standard output the names and values of all read-only variables, in the following format:

" readonly %s=%s\n", <name>, <value> The shell shall format the output, including the proper use of quoting, so that it is suitable for re-input to the shell as commands that achieve the same attributesetting results. The readonly special built-in shall conform to the utility argument syntax guidelines described in 2.10.2.

Zero.

Example: readonly Some versions of the shell exist that preserve the read-only attribute across separate invocations. . 2 allows this behavior, but does not require it. See the rationale for export ( export(1) ) for a description of the no-argument and −p output cases. In a previous draft, read-only functions were considered, but they were omitted as not being existing practice or particularly useful. Furthermore, functions must not be readonly across invocations to preclude spoofing (spoofing is the term for the practice of creating a program that acts like a well-known utility with the intent of subverting the user’s real intent) of administrative or security-relevant (or -conscious) shell scripts.

3.14 Special Built-in Utilities 253

September 1991 posix.fail