summaryrefslogtreecommitdiff
path: root/usr/src/man/man1/readonly.1
blob: 0cadf2bbee6adbee9096d207cfdffc1971783419 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
'\" te
.\" Copyright (c) 2007 Sun Microsystems, Inc. - All Rights Reserved.
.\" Copyright 1989 AT&T
.\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH READONLY 1 "April 9, 2016"
.SH NAME
readonly \- shell built-in function to protect the value of the given variable
from reassignment
.SH SYNOPSIS
.SS "sh"
.LP
.nf
\fBreadonly\fR [\fIname\fR]...
.fi

.SS "ksh"
.LP
.nf
\fB**readonly\fR [\fIname\fR [= \fIvalue\fR]]...
.fi

.LP
.nf
\fB**readonly\fR \fB-p\fR
.fi

.SS "ksh93"
.LP
.nf
\fB++readonly\fR [\fB-p\fR] [\fIname\fR [= \fIvalue\fR]]...
.fi

.SH DESCRIPTION
.SS "sh"
.LP
The given \fIname\fRs are marked \fBreadonly\fR and the values of these
\fIname\fRs may not be changed by subsequent assignment. If no arguments are
given, a list of all \fBreadonly\fR names is printed.
.SS "ksh"
.LP
The given \fIname\fRs are marked \fBreadonly\fR and these names cannot be
changed by subsequent assignment.
.sp
.LP
When \fB-p\fR is specified, \fBreadonly\fR writes to the standard output the
names and values of all read-only variables, in the following format:
.sp
.in +2
.nf
"readonly %s=%s\en", \fIname\fR, \fIvalue\fR
.fi
.in -2
.sp

.sp
.LP
if \fIname\fR is set, and:
.sp
.in +2
.nf
"readonly $s\en", \fIname\fR
.fi
.in -2
.sp

.sp
.LP
if \fIname\fR is unset.
.sp
.LP
The shell formats the output, including the proper use of quoting, so that it
is suitable for reinput to the shell as commands that achieve the same value
and \fBreadonly\fR attribute-setting results in a shell execution environment
in which:
.RS +4
.TP
1.
Variables with values set at the time they were output do not have the
\fBreadonly\fR attribute set.
.RE
.RS +4
.TP
2.
Variables that were unset at the time they were output do not have a value
at the time at which the saved output is re-input to the shell.
.RE
.sp
.LP
On this manual page, \fBksh\fR(1) commands that are preceded by one or two
\fB**\fR (asterisks) are treated specially in the following ways:
.RS +4
.TP
1.
Variable assignment lists preceding the command remain in effect when the
command completes.
.RE
.RS +4
.TP
2.
I/O redirections are processed after variable assignments.
.RE
.RS +4
.TP
3.
Errors cause a script that contains them to abort.
.RE
.RS +4
.TP
4.
Words, following a command preceded by \fB**\fR that are in the format of a
variable assignment, are expanded with the same rules as a variable assignment.
This means that tilde substitution is performed after the \fB=\fR sign and word
splitting and file name generation are not performed.
.RE
.SS "ksh93"
.LP
\fBreadonly\fR sets the \fBreadonly\fR attribute on each of the variables
specified by name which prevents their values from being changed. If
\fB=\fR\fIvalue\fR is specified, the variable name is set to \fIvalue\fR before
the variable is made \fBreadonly\fR.
.sp
.LP
If no names are specified then the names and values of all \fBreadonly\fR
variables are written to standard output.
.sp
.LP
\fBreadonly\fR is built-in to the shell as a declaration command so that field
splitting and pathname expansion are not performed on the arguments. Tilde
expansion occurs on value.
.sp
.ne 2
.na
\fB\fB-p\fR\fR
.ad
.RS 6n
Causes the output to be in a form of \fBreadonly\fR commands that can be used
as input to the shell to recreate the current set of \fBreadonly\fR variables.
.RE

.sp
.LP
On this manual page, \fBksh93\fR(1) commands that are preceded by one or two
\fB+\fR symbols are treated specially in the following ways:
.RS +4
.TP
1.
Variable assignment lists preceding the command remain in effect when the
command completes.
.RE
.RS +4
.TP
2.
I/O redirections are processed after variable assignments.
.RE
.RS +4
.TP
3.
Errors cause a script that contains them to abort.
.RE
.RS +4
.TP
4.
They are not valid function names.
.RE
.RS +4
.TP
5.
Words, following a command preceded by \fB++\fR that are in the format of a
variable assignment, are expanded with the same rules as a variable assignment.
This means that tilde substitution is performed after the \fB=\fR sign and
field splitting and file name generation are not performed.
.RE
.SH EXIT STATUS
.SS "ksh93"
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH SEE ALSO
.LP
\fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1), \fBtypeset\fR(1),
\fBattributes\fR(5)