Mark one or more variables or functions as read-only.
      readonly [-aApf] [name] ... 

   -a   Treat each name as an array variable.
   -A   restrict the variables to associative arrays.

   -p   Print a list of all readonly names (This is the default)

   -f   Mark shell functions corresponding to the names as read-only.

The given names are marked readonly and the values of these names can not be changed by subsequent assignment.

If the -f option is given, then functions corresponding to the names are so marked.

If no arguments are given, or if '-p' is given, a list of all readonly names is printed.

The '-a' option means to treat each name as an array variable.

An argument of '--' disables further option processing.

If a variable name is followed by =word, the value of the variable is set to word.

The return status is 0 unless an invalid option is encountered, one of the names is not a valid shell variable name, or -f is supplied with a name that is not a function.

This is a BASH shell builtin, to display your local syntax from the bash prompt type: help [r]eadonly

“The stupid neither forgive nor forget, the naive forgive and forget, the wise forgive but do not forget” ~ Thomas Szasz (The second sin)

Related Linux commands

chmod - Change access permissions.
env - Display, set, or remove environment variables.
export - Set an environment variable.
function - Define Function Macros.
hostname - Print or set system name.
local - Create variables.
printenv - Print environment variables.
shift - Shift positional parameters.
Equivalent PowerShell cmdlet: Set-Variable -option:ReadOnly.

Copyright © 1999-2024
Some rights reserved