ksh93 typeset -i with zero bug?

ksh93 typeset -i with zero bug?

Post by Dan Nygr » Sat, 10 Nov 2001 06:49:26



Hi -

The New Kornshell Command and Programming Language book says with
regards to typeset -i (p 178):

"If the base is other than 10, ksh prepends the base number followed
by a # sign, to the value of the variable when it is expanded."

$ /usr/bin/ksh88
$ typeset -i16 hex_data=0
$ print $hex_data
16#0
(Solaris ksh88 is OK)

$ /usr/bin/ksh93
$ typeset -i16 hex_data=0
$ print $hex_data
0
(This looks wrong)

So the behavior listed in the book doesn't seem to hold true for ksh93
(the latest release for Solaris on www.kornshell.com anyways). Is this
a bug or a feature? I encountered this problem because I had a case
statement looking for a "16#0" pattern not a "0" in a ksh93 script.
The same problem appears in Solaris dtksh.

Dan Nygren
,

 
 
 

1. ksh93 typeset in function no longer local

under ksh88,  a typeset within a function creates a variable
whose scope is limited to that function:

$ tt() {
$ echo "x=$x y=$y z=$z"
x= y= z=
$ tt
x=x y=y z=z
$ echo "x=$x y=$y z=$z"
x= y= z=

Under ksh93,  that scope is now global.  This is a major loss of
functionality and,  of course,  breaks many scripts:
$ ksh93
/home/dam/Mail
$ tt() {
$ echo "x=$x y=$y z=$z"
x= y= z=
$ tt
x=x y=y z=z
$ echo "x=$x y=$y z=$z"
x=x y=y z=z

--
Dan Mercer

Opinions expressed herein are my own and may not represent those of my employer.

2. ifconfig plumb on qfe hangs...

3. Ksh93 question: typeset and compound assignments

4. Autodetect screen with XBF server on NeoMagic

5. typeset in ksh93 is not working as expected

6. null modem PPP network...

7. ksh93 question: typeset and compound assignments

8. Why are RedHat CD's so expensive?

9. Floppy reports size as zero sectors, zero tracks, zero bytes

10. typeset bug in Solaris 2.6.1 ksh

11. Read bug in ksh93 (dtksh)

12. ksh93 backreference bug?