1READONLY(P) POSIX Programmer's Manual READONLY(P)
2
3
4
6 readonly - set the readonly attribute for variables
7
9 readonly name[=word]...
10
11 readonly -p
12
13
15 The variables whose names are specified shall be given the readonly
16 attribute. The values of variables with the readonly attribute cannot
17 be changed by subsequent assignment, nor can those variables be unset
18 by the unset utility. If the name of a variable is followed by = word,
19 then the value of that variable shall be set to word.
20
21 The readonly special built-in shall support the Base Definitions volume
22 of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
23
24 When -p is specified, readonly writes to the standard output the names
25 and values of all read-only variables, in the following format:
26
27
28 "readonly %s=%s\n", <name>, <value>
29
30 if name is set, and
31
32
33 "readonly %s\n", <name>
34
35 if name is unset.
36
37 The shell shall format the output, including the proper use of quoting,
38 so that it is suitable for reinput to the shell as commands that
39 achieve the same value and readonly attribute-setting results in a
40 shell execution environment in which:
41
42 1. Variables with values at the time they were output do not have the
43 readonly attribute set.
44
45 2. Variables that were unset at the time they were output do not have
46 a value at the time at which the saved output is reinput to the
47 shell.
48
49 When no arguments are given, the results are unspecified.
50
52 See the DESCRIPTION.
53
55 See the DESCRIPTION.
56
58 Not used.
59
61 None.
62
64 None.
65
67 Default.
68
70 See the DESCRIPTION.
71
73 The standard error shall be used only for diagnostic messages.
74
76 None.
77
79 None.
80
82 Zero.
83
85 Default.
86
87 The following sections are informative.
88
90 None.
91
93 readonly HOME PWD
94
96 Some historical shells preserve the readonly attribute across separate
97 invocations. This volume of IEEE Std 1003.1-2001 allows this behavior,
98 but does not require it.
99
100 The -p option allows portable access to the values that can be saved
101 and then later restored using, for example, a dot script. Also see the
102 RATIONALE for export for a description of the no-argument and -p output
103 cases and a related example.
104
105 Read-only functions were considered, but they were omitted as not being
106 historical practice or particularly useful. Furthermore, functions must
107 not be read-only across invocations to preclude ``spoofing'' (spoofing
108 is the term for the practice of creating a program that acts like a
109 well-known utility with the intent of subverting the real intent of the
110 user) of administrative or security-relevant (or security-conscious)
111 shell scripts.
112
114 None.
115
117 Special Built-In Utilities
118
120 Portions of this text are reprinted and reproduced in electronic form
121 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
122 -- Portable Operating System Interface (POSIX), The Open Group Base
123 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
124 Electrical and Electronics Engineers, Inc and The Open Group. In the
125 event of any discrepancy between this version and the original IEEE and
126 The Open Group Standard, the original IEEE and The Open Group Standard
127 is the referee document. The original Standard can be obtained online
128 at http://www.opengroup.org/unix/online.html .
129
130
131
132IEEE/The Open Group 2003 READONLY(P)