$ readonly myvar=1
$myvar can’t have its value changed within the global scope.
$ myvar=2 -bash: myvar: readonly variable
You can use
declare -r to enforce immutability within a local scope (eg within a
See the Linux Shell Scripting Tutorial wiki for basic examples.
See this Stack Overflow answer for more details on the differences between