Subject: Re: [ast-users] Is this a bug?
--------
 
> Or am I doing (or expecting?) something wrong?
Yes, you are using name() to define functions rather than function name.
name() functions do not create local variables since POSIX does not define
local variables.  Change each of them and try again.
> 
> I've boiled my script down quite a bit to isolate the behavior. The
> code is at the bottom.
> 
> Ignore the output for LIST in the this, I was also trying to isolate a
> problem with that not behaving the way I expect, but while isolating
> the proble with TYPE, I actually eliminated the problem with LIST. If
> I can reproduce the LIST problem maybe I'll send another question later.
> 
> This is the output I get with the OpenSolaris ksh93:
> 
> [kmcdon...@galileo] 297> ./Test1.sh
>         :TYPE=None  :LIST=Zero:
> Main    :TYPE=None  :LIST=Zero:
> Func1   :TYPE=None  :LIST=Zero:
> Func1   :TYPE=RIGHT :LIST=Zero:
> Func2   :TYPE=RIGHT :LIST=Zero:
> Func2   :TYPE=WRONG!:LIST=Zero One:
> Func2   :TYPE=WRONG!:LIST=Zero One:
> Func2   :TYPE=WRONG!:LIST=Zero One Two:
> Func1   :TYPE=WRONG!:LIST=Zero One Two:
> Main    :TYPE=WRONG!:LIST=Zero One Two:
>         :TYPE=WRONG!:LIST=Zero One Two:
> 
> However I expected to see what bash and /bin/ksh (88??) give below:
> (/export/Install/src/bin)
> [kmcdon...@galileo] 298>bash ./Test1.sh
>         :TYPE=None  :LIST=Zero:
> Main    :TYPE=None  :LIST=Zero:
> Func1   :TYPE=None  :LIST=Zero:
> Func1   :TYPE=RIGHT :LIST=Zero:
> Func2   :TYPE=RIGHT :LIST=Zero:
> Func2   :TYPE=WRONG!:LIST=Zero One:
> Func2   :TYPE=RIGHT :LIST=Zero One:
> Func2   :TYPE=WRONG!:LIST=Zero One Two:
> Func1   :TYPE=RIGHT :LIST=Zero One Two:
> Main    :TYPE=RIGHT :LIST=Zero One Two:
>         :TYPE=RIGHT :LIST=Zero One Two:
> (/export/Install/src/bin)
> [kmcdon...@galileo] 299>ksh ./Test1.sh
>         :TYPE=None  :LIST=Zero:
> Main    :TYPE=None  :LIST=Zero:
> Func1   :TYPE=None  :LIST=Zero:
> Func1   :TYPE=RIGHT :LIST=Zero:
> Func2   :TYPE=RIGHT :LIST=Zero:
> Func2   :TYPE=WRONG!:LIST=Zero One:
> Func2   :TYPE=RIGHT :LIST=Zero One:
> Func2   :TYPE=WRONG!:LIST=Zero One Two:
> Func1   :TYPE=RIGHT :LIST=Zero One Two:
> Main    :TYPE=RIGHT :LIST=Zero One Two:
>         :TYPE=RIGHT :LIST=Zero One Two:
> 
> Here's the code. Shouldn't the 'typeset TYPE' in Func2 make TYPE a
> local variable for that function only? I expected it to hide the
> global TYPE, but it shouldn't change the global TYPE, should it?
> 
> (/export/Install/src/bin)
> [kmcdon...@galileo] 300>cat Test1.sh
> #!/bin/ksh93
> TYPE="None  "
> LIST="Zero"
> 
> Main()
>   {
>     echo "Main    :TYPE=${TYPE}:LIST=${LIST}:"
>     Func1 "$...@}"
>     echo "Main    :TYPE=${TYPE}:LIST=${LIST}:"
>   }
> 
> Func1()
>   {
>     echo "Func1   :TYPE=${TYPE}:LIST=${LIST}:"
>     TYPE="RIGHT "
> 
>     echo "Func1   :TYPE=${TYPE}:LIST=${LIST}:"
>     Func2 One
>     Func2 Two
>     echo "Func1   :TYPE=${TYPE}:LIST=${LIST}:"
>   }
> 
> Func2()
>   {
>     echo "Func2   :TYPE=${TYPE}:LIST=${LIST}:"
>     LIST="${LIST} ${1}"
>     typeset TYPE="WRONG!"
>     echo "Func2   :TYPE=${TYPE}:LIST=${LIST}:"
>   }
> 
> echo "        :TYPE=${TYPE}:LIST=${LIST}:"
> Main "$@"
> echo "        :TYPE=${TYPE}:LIST=${LIST}:"
> 
> 
> Am I nuts?
Good chance you are.
> 
> Thanks!
> 
>  -Kyle
> 

David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to