READONLY(1)                POSIX Programmer's Manual               READONLY(1)



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

NNAAMMEE
       readonly -- set the readonly attribute for variables

SSYYNNOOPPSSIISS
       readonly name[[=_w_o_r_d]]...

       readonly -p

DDEESSCCRRIIPPTTIIOONN
       The variables whose _n_a_m_es are specified shall be given the _r_e_a_d_o_n_l_y
       attribute. The values of variables with the _r_e_a_d_o_n_l_y attribute cannot
       be changed by subsequent assignment, nor can those variables be unset
       by the _u_n_s_e_t utility. If the name of a variable is followed by =_w_o_r_d,
       then the value of that variable shall be set to _w_o_r_d.

       The _r_e_a_d_o_n_l_y special built-in shall support the Base Definitions volume
       of POSIX.1-2017, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s.

       When --pp is specified, _r_e_a_d_o_n_l_y writes to the standard output the names
       and values of all read-only variables, in the following format:


           "readonly %s=%s\n", <_n_a_m_e>, <_v_a_l_u_e>

       if _n_a_m_e is set, and


           "readonly %s\n", <_n_a_m_e>

       if _n_a_m_e is unset.

       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 _r_e_a_d_o_n_l_y attribute-setting results in a
       shell execution environment in which:

        1. Variables with values at the time they were output do not have the
           _r_e_a_d_o_n_l_y attribute set.

        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 reinput to the
           shell.

       When no arguments are given, the results are unspecified.

OOPPTTIIOONNSS
       See the DESCRIPTION.

OOPPEERRAANNDDSS
       See the DESCRIPTION.

SSTTDDIINN
       Not used.

IINNPPUUTT FFIILLEESS
       None.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       None.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       See the DESCRIPTION.

SSTTDDEERRRR
       The standard error shall be used only for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
        0    All _n_a_m_e operands were successfully marked readonly.

       >0    At least one _n_a_m_e could not be marked readonly, or the --pp option
             was specified and an error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

EEXXAAMMPPLLEESS
       readonly HOME PWD

RRAATTIIOONNAALLEE
       Some historical shells preserve the _r_e_a_d_o_n_l_y attribute across separate
       invocations. This volume of POSIX.1-2017 allows this behavior, but does
       not require it.

       The --pp option allows portable access to the values that can be saved
       and then later restored using, for example, a _d_o_t script. Also see the
       RATIONALE for _e_x_p_o_r_t for a description of the no-argument and --pp output
       cases and a related example.

       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.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _S_e_c_t_i_o_n _2_._1_4, _S_p_e_c_i_a_l _B_u_i_l_t_-_I_n _U_t_i_l_i_t_i_e_s

       The Base Definitions volume of POSIX.1-2017, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y
       _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 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 .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                          READONLY(1)
