readonly - Set read-only attribute for variables

Synopsis

readonly [ -p ] [ name [ =value ] ... ]

Description

You can use readonly to set the read-only attribute for the variables specified by name. A variable with the read-only attribute cannot have its value changed by a subsequent assignment and cannot be unset.

Note that qsh can change the value of a variable with the read-only attribute. For example, if PWD has the read-only attribute, it's value will be changed when you change the current working directory.

When no arguments are specified, qsh displays a list of the variables with the read-only attribute and their values.

Options

-p
Precede each line of the output with the word "readonly " so it is displayed in a re-enterable format.

Operands

Each name specifies a variable in the current environment. If a value is also specified, the value of the variable is updated before setting the read-only attribute.

Exit status

  • 0 when successful.
  • >0 when unsuccessful.
Examples
  1. Set the read-only attribute for an existing variable:
    readonly ALPHA
  2. Set the value and read-only attribute of a new variable:
    readonly ALPHA=one
  3. List all variables with the read-only attribute:
    readonly