1readonly(1)                      User Commands                     readonly(1)
2
3
4

NAME

6       readonly  -  shell  built-in function to protect the value of the given
7       variable from reassignment
8

SYNOPSIS

10   sh
11       readonly [name]...
12
13
14   ksh
15       **readonly [name [= value]]...
16
17
18       **readonly -p
19
20
21   ksh93
22       ++readonly [-p] [name [= value]]...
23
24

DESCRIPTION

26   sh
27       The given names are marked readonly and the values of the  these  names
28       may not be changed by subsequent assignment. If no arguments are given,
29       a list of all readonly names is printed.
30
31   ksh
32       The given names are marked readonly and these names cannot  be  changed
33       by subsequent assignment.
34
35
36       When  -p is specified, readonly writes to the standard output the names
37       and values of all read-only variables, in the following format:
38
39         "readonly %s=%s\n", name, value
40
41
42
43
44       if name is set, and:
45
46         "readonly $s\n", name
47
48
49
50
51       if name is unset.
52
53
54       The shell formats the output, including the proper use of  quoting,  so
55       that  it  is suitable for reinput to the shell as commands that achieve
56       the same value and readonly attribute-setting results in a shell execu‐
57       tion environment in which:
58
59           1.     Variables  with  values  set at the time they were output do
60                  not have the readonly attribute set.
61
62           2.     Variables that were unset at the time they  were  output  do
63                  not  have  a  value at the time at which the saved output is
64                  re-input to the shell.
65
66
67       On this manual page, ksh(1) commands that are preceded by one or two **
68       (asterisks) are treated specially in the following ways:
69
70           1.     Variable  assignment  lists  preceding the command remain in
71                  effect when the command completes.
72
73           2.     I/O redirections are processed after variable assignments.
74
75           3.     Errors cause a script that contains them to abort.
76
77           4.     Words, following a command preceded by ** that  are  in  the
78                  format  of a variable assignment, are expanded with the same
79                  rules as a variable assignment. This means that  tilde  sub‐
80                  stitution  is  performed after the = sign and word splitting
81                  and file name generation are not performed.
82
83   ksh93
84       readonly sets the readonly attribute on each of the variables specified
85       by  name  which  prevents their values from being changed. If =value is
86       specified, the variable name is set to value  before  the  variable  is
87       made readonly.
88
89
90       If  no  names  are  specified then the names and values of all readonly
91       variables are written to standard output.
92
93
94       readonly is built-in to the shell as  a  declaration  command  so  that
95       field  splitting  and pathname expansion are not performed on the argu‐
96       ments. Tilde expansion occurs on value.
97
98       -p    Causes the output to be in a form of readonly commands  that  can
99             be  used  as  input  to  the shell to recreate the current set of
100             readonly variables.
101
102
103
104       On this manual page, ksh93(1) commands that are preceded by one or  two
105       + symbols are treated specially in the following ways:
106
107           1.     Variable  assignment  lists  preceding the command remain in
108                  effect when the command completes.
109
110           2.     I/O redirections are processed after variable assignments.
111
112           3.     Errors cause a script that contains them to abort.
113
114           4.     They are not valid function names.
115
116           5.     Words, following a command preceded by ++ that  are  in  the
117                  format  of a variable assignment, are expanded with the same
118                  rules as a variable assignment. This means that  tilde  sub‐
119                  stitution  is performed after the = sign and field splitting
120                  and file name generation are not performed.
121

EXIT STATUS

123   ksh93
124       The following exit values are returned:
125
126       0     Successful completion.
127
128
129       >0    An error occurred.
130
131

ATTRIBUTES

133       See attributes(5) for descriptions of the following attributes:
134
135
136
137
138       ┌─────────────────────────────┬─────────────────────────────┐
139       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
140       ├─────────────────────────────┼─────────────────────────────┤
141       │Availability                 │SUNWcsu                      │
142       └─────────────────────────────┴─────────────────────────────┘
143

SEE ALSO

145       ksh(1), ksh93(1), sh(1), typeset(1), attributes(5)
146
147
148
149SunOS 5.11                        2 Nov 2007                       readonly(1)
Impressum