A ksh script that my group has been using for a long time in Solaris
breaks when running under ksh93 (both on Solaris and OpenSolaris). I
traced the problem to the fact that local variables declared with
"typeset -r" get a "varname: is read only" error when the local function
is called multiple times. Here's the script I wrote to test it:
#!/bin/ksh
Local1() {
typeset -r varname="local1"
echo $varname
}
Local2() {
typeset -r varname="local2"
echo $varname
}
typeset -r varname="global"
echo $varname
Local1
Local2
echo $varname
Output with ksh:
global
local1
local2
global
Output with ksh93:
global
testscript: line 3: varname: is read only
So is the bug in ksh93, or is ksh being too lenient with its use of
"typeset -r"?
-- Alan