posix/ksh: Constants aren't; Variables won't

posix/ksh: Constants aren't; Variables won't

Post by J. Kenneth Gent » Sat, 07 May 1994 23:23:21



Using the posix and ksh on both AIX and HPUX, 'typeset -r' isn't behaving
as I think it should.  For example:

-> typeset -ir MAX_ERRORS=50
-> typeset -ir
...
MAX_ERRORS=50
...
-> MAX_ERRORS=51
ksh: MAX_ERRORS: This variable is read only.

OK, this consistent with my understanding of the function.  However,
the following confuses me:

-> ((MAX_ERRORS=51))
gentlejk-> typeset -ir      
...
MAX_ERRORS=51
...
-> MAX_ERRORS=51    
ksh: MAX_ERRORS: This variable is read only.
->
Huh?  Why does the shell allow me to change this supposedly read-only
variable?

BTW, I realize that "((...))" should be "$((...))" for arithmetic
substitution.  Note that

-> MAX_ERRORS=$(($MAX_ERRORS+1))
ksh: MAX_ERRORS: This variable is read only.

gives the appropriate behavior.

        Thanks!

                Ken
--
===============================================================================
J. Kenneth Gentle (Ken)           | Phone: (302) 733-3052   FAX:(302) 774-7321

===============================================================================