Merge commit '008b34be09d7b9c3e7a18d3ce9ef8b5c4f4ff8b8'
[unleashed.git] / share / man / man1 / readonly.1
blob0cadf2bbee6adbee9096d207cfdffc1971783419
1 '\" te
2 .\" Copyright (c) 2007 Sun Microsystems, Inc. - All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures
5 .\" 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.
6 .\" 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.
7 .\" 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]
8 .TH READONLY 1 "April 9, 2016"
9 .SH NAME
10 readonly \- shell built-in function to protect the value of the given variable
11 from reassignment
12 .SH SYNOPSIS
13 .SS "sh"
14 .LP
15 .nf
16 \fBreadonly\fR [\fIname\fR]...
17 .fi
19 .SS "ksh"
20 .LP
21 .nf
22 \fB**readonly\fR [\fIname\fR [= \fIvalue\fR]]...
23 .fi
25 .LP
26 .nf
27 \fB**readonly\fR \fB-p\fR
28 .fi
30 .SS "ksh93"
31 .LP
32 .nf
33 \fB++readonly\fR [\fB-p\fR] [\fIname\fR [= \fIvalue\fR]]...
34 .fi
36 .SH DESCRIPTION
37 .SS "sh"
38 .LP
39 The given \fIname\fRs are marked \fBreadonly\fR and the values of these
40 \fIname\fRs may not be changed by subsequent assignment. If no arguments are
41 given, a list of all \fBreadonly\fR names is printed.
42 .SS "ksh"
43 .LP
44 The given \fIname\fRs are marked \fBreadonly\fR and these names cannot be
45 changed by subsequent assignment.
46 .sp
47 .LP
48 When \fB-p\fR is specified, \fBreadonly\fR writes to the standard output the
49 names and values of all read-only variables, in the following format:
50 .sp
51 .in +2
52 .nf
53 "readonly %s=%s\en", \fIname\fR, \fIvalue\fR
54 .fi
55 .in -2
56 .sp
58 .sp
59 .LP
60 if \fIname\fR is set, and:
61 .sp
62 .in +2
63 .nf
64 "readonly $s\en", \fIname\fR
65 .fi
66 .in -2
67 .sp
69 .sp
70 .LP
71 if \fIname\fR is unset.
72 .sp
73 .LP
74 The shell formats the output, including the proper use of quoting, so that it
75 is suitable for reinput to the shell as commands that achieve the same value
76 and \fBreadonly\fR attribute-setting results in a shell execution environment
77 in which:
78 .RS +4
79 .TP
81 Variables with values set at the time they were output do not have the
82 \fBreadonly\fR attribute set.
83 .RE
84 .RS +4
85 .TP
87 Variables that were unset at the time they were output do not have a value
88 at the time at which the saved output is re-input to the shell.
89 .RE
90 .sp
91 .LP
92 On this manual page, \fBksh\fR(1) commands that are preceded by one or two
93 \fB**\fR (asterisks) are treated specially in the following ways:
94 .RS +4
95 .TP
97 Variable assignment lists preceding the command remain in effect when the
98 command completes.
99 .RE
100 .RS +4
103 I/O redirections are processed after variable assignments.
105 .RS +4
108 Errors cause a script that contains them to abort.
110 .RS +4
113 Words, following a command preceded by \fB**\fR that are in the format of a
114 variable assignment, are expanded with the same rules as a variable assignment.
115 This means that tilde substitution is performed after the \fB=\fR sign and word
116 splitting and file name generation are not performed.
118 .SS "ksh93"
120 \fBreadonly\fR sets the \fBreadonly\fR attribute on each of the variables
121 specified by name which prevents their values from being changed. If
122 \fB=\fR\fIvalue\fR is specified, the variable name is set to \fIvalue\fR before
123 the variable is made \fBreadonly\fR.
126 If no names are specified then the names and values of all \fBreadonly\fR
127 variables are written to standard output.
130 \fBreadonly\fR is built-in to the shell as a declaration command so that field
131 splitting and pathname expansion are not performed on the arguments. Tilde
132 expansion occurs on value.
134 .ne 2
136 \fB\fB-p\fR\fR
138 .RS 6n
139 Causes the output to be in a form of \fBreadonly\fR commands that can be used
140 as input to the shell to recreate the current set of \fBreadonly\fR variables.
145 On this manual page, \fBksh93\fR(1) commands that are preceded by one or two
146 \fB+\fR symbols are treated specially in the following ways:
147 .RS +4
150 Variable assignment lists preceding the command remain in effect when the
151 command completes.
153 .RS +4
156 I/O redirections are processed after variable assignments.
158 .RS +4
161 Errors cause a script that contains them to abort.
163 .RS +4
166 They are not valid function names.
168 .RS +4
171 Words, following a command preceded by \fB++\fR that are in the format of a
172 variable assignment, are expanded with the same rules as a variable assignment.
173 This means that tilde substitution is performed after the \fB=\fR sign and
174 field splitting and file name generation are not performed.
176 .SH EXIT STATUS
177 .SS "ksh93"
179 The following exit values are returned:
181 .ne 2
183 \fB\fB0\fR\fR
185 .RS 6n
186 Successful completion.
190 .ne 2
192 \fB\fB>0\fR\fR
194 .RS 6n
195 An error occurred.
198 .SH SEE ALSO
200 \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1), \fBtypeset\fR(1),
201 \fBattributes\fR(5)