Strange associative array bug in ksh93

Strange associative array bug in ksh93

Post by Dan Merc » Fri, 07 May 1999 04:00:00



I found the following bug in ksh93.  Using the following script:

   #!/opt/ksh93/bin/sh

   typeset -A TEST

   TEST=( [abc]=1 [def]=1 [ghi]=1 [jkl]=1 [mno]=1 )

   [[ -x $0 ]] &&
      ll $0

I get:

/usr/local/bin/ksh93bug: line 7: [[ -x /usr/local/bin/ksh93bug ]]: not found

apparently,  if a "[[ condition ]]" immediately follows the setting
of an associative array using the above syntax,  the entire
"[[ condition ]]" is treated as a single word.  If I use

   #!/opt/ksh93/bin/sh

   typeset -A TEST

   TEST=( [abc]=1 [def]=1 [ghi]=1 [jkl]=1 [mno]=1 )

   if [[ -x $0 ]];then ll $0;fi

no problem.  Or if I:

   #!/opt/ksh93/bin/sh

   typeset -A TEST

   TEST=( [abc]=1 [def]=1 [ghi]=1 [jkl]=1 [mno]=1 )

   : # nop to hack around bug

   [[ -x $0 ]] &&
      ll $0

$ ksh93 -c 'print ${.sh.version}'
Version M-12/28/93e

$ dtksh -c 'print ${.sh.version}'
Version M-12/28/93d

--
Dan Mercer

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

 
 
 

1. Loop thru Associative Array in KSH93 ?

Hi All --

I have an associative array full of things, that I need to
process one at a time. I know how to load the associative
array, but how do I walk thru it one key at a time ???

Could it be as easy as a "for name in ... done" loop ??

Also, has anyone sorted an associtive array in ksh93 ?

Thanks in advance,
Andy.

2. Is symlink() an atomic operation?

3. How to get all keys of associative array?

4. Preferred freeware distribution?

5. AWK: Print multi-dim associative array ??

6. Modem Setup

7. associative array hack for bash

8. Where is Linux 1.2.8 ?

9. Associative Arrays in Korn

10. (patch for Bash) disk-based associative array using gdbm(3)

11. Subject: Ksh93 question: special built-ins: why are they special?

12. Referencing non-unique associative array elements

13. Wrong sorting of associative arrays??