man-pages/man1p/readonly.1p

152 lines
3.9 KiB
Groff

.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved
.TH "READONLY" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
.\" readonly
.SH NAME
readonly \- set the readonly attribute for variables
.SH SYNOPSIS
.LP
\fBreadonly name\fP\fB[\fP\fB=\fP\fIword\fP\fB]\fP\fB...
.br
.sp
readonly -p
.br
\fP
.SH DESCRIPTION
.LP
The variables whose \fIname\fPs are specified shall be given the \fIreadonly\fP
attribute. The values of variables with the
\fIreadonly\fP attribute cannot be changed by subsequent assignment,
nor can those variables be unset by the \fIunset\fP utility. If the
name of a variable is followed by = \fIword\fP, then the value of
that
variable shall be set to \fIword\fP.
.LP
The \fIreadonly\fP special built-in shall support the Base Definitions
volume of IEEE\ Std\ 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
.LP
When \fB-p\fP is specified, \fIreadonly\fP writes to the standard
output the names and values of all read-only variables, in
the following format:
.sp
.RS
.nf
\fB"readonly %s=%s\\n", <\fP\fIname\fP\fB>, <\fP\fIvalue\fP\fB>
\fP
.fi
.RE
.LP
if \fIname\fP is set, and
.sp
.RS
.nf
\fB"readonly %s\\n", <\fP\fIname\fP\fB>
\fP
.fi
.RE
.LP
if \fIname\fP is unset.
.LP
The shell shall format 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 \fIreadonly\fP attribute-setting
results in a shell execution environment in which:
.IP " 1." 4
Variables with values at the time they were output do not have the
\fIreadonly\fP attribute set.
.LP
.IP " 2." 4
Variables that were unset at the time they were output do not have
a value at the time at which the saved output is reinput to
the shell.
.LP
.LP
When no arguments are given, the results are unspecified.
.SH OPTIONS
.LP
See the DESCRIPTION.
.SH OPERANDS
.LP
See the DESCRIPTION.
.SH STDIN
.LP
Not used.
.SH INPUT FILES
.LP
None.
.SH ENVIRONMENT VARIABLES
.LP
None.
.SH ASYNCHRONOUS EVENTS
.LP
Default.
.SH STDOUT
.LP
See the DESCRIPTION.
.SH STDERR
.LP
The standard error shall be used only for diagnostic messages.
.SH OUTPUT FILES
.LP
None.
.SH EXTENDED DESCRIPTION
.LP
None.
.SH EXIT STATUS
.LP
Zero.
.SH CONSEQUENCES OF ERRORS
.LP
Default.
.LP
\fIThe following sections are informative.\fP
.SH APPLICATION USAGE
.LP
None.
.SH EXAMPLES
.sp
.RS
.nf
\fBreadonly HOME PWD
\fP
.fi
.RE
.SH RATIONALE
.LP
Some historical shells preserve the \fIreadonly\fP attribute across
separate invocations. This volume of
IEEE\ Std\ 1003.1-2001 allows this behavior, but does not require
it.
.LP
The \fB-p\fP option allows portable access to the values that can
be saved and then later restored using, for example, a \fIdot\fP script.
Also see the RATIONALE for \fIexport\fP
for a description of the no-argument and \fB-p\fP output cases and
a related example.
.LP
Read-only functions were considered, but they were omitted as not
being historical practice or particularly useful. Furthermore,
functions must not be read-only across invocations to preclude ``spoofing''
(spoofing is the term for the practice of creating a
program that acts like a well-known utility with the intent of subverting
the real intent of the user) of administrative or
security-relevant (or security-conscious) shell scripts.
.SH FUTURE DIRECTIONS
.LP
None.
.SH SEE ALSO
.LP
\fISpecial Built-In Utilities\fP
.SH COPYRIGHT
Portions of this text are reprinted and reproduced in electronic form
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
-- Portable Operating System Interface (POSIX), The Open Group Base
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
Electrical and Electronics Engineers, Inc and The Open Group. In the
event of any discrepancy between this version and the original IEEE and
The Open Group Standard, the original IEEE and The Open Group Standard
is the referee document. The original Standard can be obtained online at
http://www.opengroup.org/unix/online.html .