'\" te .\" Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. .\" Copyright 1989 AT&T .\" Portions Copyright (c) 1982-2007 AT&T Knowledge Ventures .TH readonly 1 "12 Jul 2011" "SunOS 5.11" "User Commands" .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 "ksh88" .LP .nf \fB**readonly\fR [\fIname\fR [= \fIvalue\fR]]... .fi .LP .nf \fB**readonly\fR \fB-p\fR .fi .SS "ksh" .LP .nf \fB++readonly\fR [\fB-p\fR] [\fIname\fR [= \fIvalue\fR]]... .fi .SH DESCRIPTION .SS "sh" .sp .LP The given \fIname\fRs are marked \fBreadonly\fR and the values of the 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 "ksh88" .sp .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, \fBksh88\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 "ksh" .sp .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 .mk .na \fB\fB-p\fR\fR .ad .RS 6n .rt 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, \fBksh\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 "ksh" .sp .LP The following exit values are returned: .sp .ne 2 .mk .na \fB\fB0\fR\fR .ad .RS 6n .rt Successful completion. .RE .sp .ne 2 .mk .na \fB\fB>0\fR\fR .ad .RS 6n .rt An error occurred. .RE .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ Availabilitysystem/core-os .TE .SH SEE ALSO .sp .LP \fBksh\fR(1), \fBksh88\fR(1), \fBsh\fR(1), \fBtypeset\fR(1), \fBattributes\fR(5)