672 xargs doesn't support -0
[illumos-gate.git] / usr / src / man / man1 / readonly.1
blob40f6f7c0a5880ee0b140dc4ba6ee212919b6004c
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 "Nov 2, 2007"
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 .sp
39 .LP
40 The given \fIname\fRs are marked \fBreadonly\fR and the values of the these
41 \fIname\fRs may not be changed by subsequent assignment. If no arguments are
42 given, a list of all \fBreadonly\fR names is printed.
43 .SS "ksh"
44 .sp
45 .LP
46 The given \fIname\fRs are marked \fBreadonly\fR and these names cannot be
47 changed by subsequent assignment.
48 .sp
49 .LP
50 When \fB-p\fR is specified, \fBreadonly\fR writes to the standard output the
51 names and values of all read-only variables, in the following format:
52 .sp
53 .in +2
54 .nf
55 "readonly %s=%s\en", \fIname\fR, \fIvalue\fR
56 .fi
57 .in -2
58 .sp
60 .sp
61 .LP
62 if \fIname\fR is set, and:
63 .sp
64 .in +2
65 .nf
66 "readonly $s\en", \fIname\fR
67 .fi
68 .in -2
69 .sp
71 .sp
72 .LP
73 if \fIname\fR is unset.
74 .sp
75 .LP
76 The shell formats the output, including the proper use of quoting, so that it
77 is suitable for reinput to the shell as commands that achieve the same value
78 and \fBreadonly\fR attribute-setting results in a shell execution environment
79 in which:
80 .RS +4
81 .TP
83 Variables with values set at the time they were output do not have the
84 \fBreadonly\fR attribute set.
85 .RE
86 .RS +4
87 .TP
89 Variables that were unset at the time they were output do not have a value
90 at the time at which the saved output is re-input to the shell.
91 .RE
92 .sp
93 .LP
94 On this manual page, \fBksh\fR(1) commands that are preceded by one or two
95 \fB**\fR (asterisks) are treated specially in the following ways:
96 .RS +4
97 .TP
99 Variable assignment lists preceding the command remain in effect when the
100 command completes.
102 .RS +4
105 I/O redirections are processed after variable assignments.
107 .RS +4
110 Errors cause a script that contains them to abort.
112 .RS +4
115 Words, following a command preceded by \fB**\fR that are in the format of a
116 variable assignment, are expanded with the same rules as a variable assignment.
117 This means that tilde substitution is performed after the \fB=\fR sign and word
118 splitting and file name generation are not performed.
120 .SS "ksh93"
123 \fBreadonly\fR sets the \fBreadonly\fR attribute on each of the variables
124 specified by name which prevents their values from being changed. If
125 \fB=\fR\fIvalue\fR is specified, the variable name is set to \fIvalue\fR before
126 the variable is made \fBreadonly\fR.
129 If no names are specified then the names and values of all \fBreadonly\fR
130 variables are written to standard output.
133 \fBreadonly\fR is built-in to the shell as a declaration command so that field
134 splitting and pathname expansion are not performed on the arguments. Tilde
135 expansion occurs on value.
137 .ne 2
139 \fB\fB-p\fR\fR
141 .RS 6n
142 Causes the output to be in a form of \fBreadonly\fR commands that can be used
143 as input to the shell to recreate the current set of \fBreadonly\fR variables.
148 On this manual page, \fBksh93\fR(1) commands that are preceded by one or two
149 \fB+\fR symbols are treated specially in the following ways:
150 .RS +4
153 Variable assignment lists preceding the command remain in effect when the
154 command completes.
156 .RS +4
159 I/O redirections are processed after variable assignments.
161 .RS +4
164 Errors cause a script that contains them to abort.
166 .RS +4
169 They are not valid function names.
171 .RS +4
174 Words, following a command preceded by \fB++\fR that are in the format of a
175 variable assignment, are expanded with the same rules as a variable assignment.
176 This means that tilde substitution is performed after the \fB=\fR sign and
177 field splitting and file name generation are not performed.
179 .SH EXIT STATUS
180 .SS "ksh93"
183 The following exit values are returned:
185 .ne 2
187 \fB\fB0\fR\fR
189 .RS 6n
190 Successful completion.
194 .ne 2
196 \fB\fB>0\fR\fR
198 .RS 6n
199 An error occurred.
202 .SH SEE ALSO
205 \fBksh\fR(1), \fBksh93\fR(1), \fBsh\fR(1), \fBtypeset\fR(1),
206 \fBattributes\fR(5)