-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Or am I doing (or expecting?) something wrong?

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 problem 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?

Thanks!

 -Kyle

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (MingW32)
 
iQEcBAEBAgAGBQJM2tNrAAoJEEADRM+bKN5wzSAH/ivXKINV1msEMgnWPRomh/o6
m9/iHGy56UD5PwzqmvG2Esa4xZT4tLJiTkgkvQE3+gPI3y+wYiq7KdK0laHfw26i
SnsXGRPosLslyMlueQmQwySYF203W016ZX2GnhGRckorrWdoKtZ7CDEJD7IomUlg
Jg4bXwZX5c7HJDCgQgAr4+xfk5E0z2MZztof/eSDVDLNHuRMnk1bWzk8VwtsjbYp
jAtwqSd/xn2go1uGvKnXXdEMwIUeHhmUv64z77tAMCrRHhDU+yJF7fqrt6mrJkut
9W8q4/PQX/HIv+yvEL3ZfWoq87iI5PzxvPQxo3b5uHLWM6L7hRFKmS/dj/Aqex4=
=O6xt
-----END PGP SIGNATURE-----

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

Reply via email to