1READONLY(1P)               POSIX Programmer's Manual              READONLY(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       readonly — set the readonly attribute for variables
13

SYNOPSIS

15       readonly name[=word]...
16
17       readonly -p
18

DESCRIPTION

20       The variables whose names are specified shall  be  given  the  readonly
21       attribute.  The  values of variables with the readonly attribute cannot
22       be changed by subsequent assignment, nor can those variables  be  unset
23       by  the  unset utility. If the name of a variable is followed by =word,
24       then the value of that variable shall be set to word.
25
26       The readonly special built-in shall support the Base Definitions volume
27       of POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
28
29       When  -p is specified, readonly writes to the standard output the names
30       and values of all read-only variables, in the following format:
31
32
33           "readonly %s=%s\n", <name>, <value>
34
35       if name is set, and
36
37
38           "readonly %s\n", <name>
39
40       if name is unset.
41
42       The shell shall format the output, including the proper use of quoting,
43       so  that  it  is  suitable  for  reinput  to the shell as commands that
44       achieve the same value and  readonly  attribute-setting  results  in  a
45       shell execution environment in which:
46
47        1. Variables  with values at the time they were output do not have the
48           readonly attribute set.
49
50        2. Variables that were unset at the time they were output do not  have
51           a  value  at  the  time at which the saved output is reinput to the
52           shell.
53
54       When no arguments are given, the results are unspecified.
55

OPTIONS

57       See the DESCRIPTION.
58

OPERANDS

60       See the DESCRIPTION.
61

STDIN

63       Not used.
64

INPUT FILES

66       None.
67

ENVIRONMENT VARIABLES

69       None.
70

ASYNCHRONOUS EVENTS

72       Default.
73

STDOUT

75       See the DESCRIPTION.
76

STDERR

78       The standard error shall be used only for diagnostic messages.
79

OUTPUT FILES

81       None.
82

EXTENDED DESCRIPTION

84       None.
85

EXIT STATUS

87        0    All name operands were successfully marked readonly.
88
89       >0    At least one name could not be marked readonly, or the -p  option
90             was specified and an error occurred.
91

CONSEQUENCES OF ERRORS

93       Default.
94
95       The following sections are informative.
96

APPLICATION USAGE

98       None.
99

EXAMPLES

101       readonly HOME PWD
102

RATIONALE

104       Some  historical shells preserve the readonly attribute across separate
105       invocations. This volume of POSIX.1‐2017 allows this behavior, but does
106       not require it.
107
108       The  -p  option  allows portable access to the values that can be saved
109       and then later restored using, for example, a dot script. Also see  the
110       RATIONALE for export for a description of the no-argument and -p output
111       cases and a related example.
112
113       Read-only functions were considered, but they were omitted as not being
114       historical practice or particularly useful. Furthermore, functions must
115       not be read-only across invocations to preclude ``spoofing''  (spoofing
116       is  the  term  for  the practice of creating a program that acts like a
117       well-known utility with the intent of subverting the real intent of the
118       user)  of  administrative  or security-relevant (or security-conscious)
119       shell scripts.
120

FUTURE DIRECTIONS

122       None.
123

SEE ALSO

125       Section 2.14, Special Built-In Utilities
126
127       The Base Definitions volume of POSIX.1‐2017, Section 12.2, Utility Syn‐
128       tax Guidelines
129
131       Portions  of  this text are reprinted and reproduced in electronic form
132       from IEEE Std 1003.1-2017, Standard for Information Technology --  Por‐
133       table  Operating System Interface (POSIX), The Open Group Base Specifi‐
134       cations Issue 7, 2018 Edition, Copyright (C) 2018 by the  Institute  of
135       Electrical  and  Electronics Engineers, Inc and The Open Group.  In the
136       event of any discrepancy between this version and the original IEEE and
137       The  Open Group Standard, the original IEEE and The Open Group Standard
138       is the referee document. The original Standard can be  obtained  online
139       at http://www.opengroup.org/unix/online.html .
140
141       Any  typographical  or  formatting  errors that appear in this page are
142       most likely to have been introduced during the conversion of the source
143       files  to  man page format. To report such errors, see https://www.ker
144       nel.org/doc/man-pages/reporting_bugs.html .
145
146
147
148IEEE/The Open Group                  2017                         READONLY(1P)
Impressum