On 7/31/13 8:16 AM, David Korn wrote:
> cc: [email protected] 
> Subject: Re: Problem in ksh93 93t+ (my reference 46004)
> --------
>
>
>> AIX 6.1 (ddaap128/ Version M-12/28/93e):
>> 6100-06-06-1140
>>
>> hdisk0 root@wlc:/ set | grep -i vers
>> .sh.version='Version M-12/28/93e'
>>
>> $ ksh93
>> $ typeset -A SRL_TM
>> $ SRL_TM[100D6AP]=1
>> $ print -- ${SRL_TM[100D6AP]}
>> 1
>> $ print -- ${!SRL_TM[100D6AP]}
>> 100D6AP          <<<<<<<<<<<< this looks good
>> -------------------------------------------------------
>> AIX 7.1 (poaim001/ Version M 93t+ 2009-05-01):
>> 7100-02-02-1316
>>
>> hdisk0 root@wlb:/ echo $KSH_VERSION
>> Version M 93t+ 2009-05-01
>>
>> $ ksh93
>> $ typeset -A SRL_TM
>> $ SRL_TM[100D6AP]=1
>> $ print -- ${SRL_TM[100D6AP]}
>> 1
>> $ print -- ${!SRL_TM[100D6AP]}
>> SRL_TM[100D6AP]      <<<<<<<< this is different now
>> ------------------------------------------------------------------
>> test with linux
>>
>> $ ksh93
>> $ echo $KSH_VERSION
>> Version AJM 93t+ 2010-06-21
>> $ typeset -A SRL_TM
>> $ SRL_TM[100D6AP]=1
>> $ print -- ${SRL_TM[100D6AP]}
>> 1
>> $ print -- ${!SRL_TM[100D6AP]}
>> SRL_TM[100D6AP]
>> ------------------------------------------------------------------
>> so the problem is also in place with Linux!
>>
>> The according ksh93 man page reads:
>>
>> ${!vname[subscript]}
>>
>>    Expands to name of the subscript unless subscript is *, @. or of the
>>    form sub1 .. sub2. When subscript is *, the list of array subscripts
>>    for vname is generated. For a variable that is not an array, the
>>    value is 0 if the variable is set. Otherwise it is null. When
>>    subscript is @, same as above, except that when used in double
>>    quotes, each array subscript yields a separate argument. When
>>    subscript is of the form sub1 .. sub2 it expands to the list of
>>    subscripts between sub1 and sub2 inclusive using the same quoting
>>    rules as @.
>>
>> According to that description I would see the new behaviour as defect.
>> Do you agree with that?
>>
>> Best Regards,
>>
> I don't recall making this change and at least on first reading
> it appears to be an unintended change, I believe that it is a
> bug.  If I can find a reason for the change, I will let you
> know.  Meanwhile it is on my buglist for ksh93v.
>
> David Korn
> [email protected]
> _______________________________________________
> ast-users mailing list
> [email protected]
> http://lists.research.att.com/mailman/listinfo/ast-users

    Some additional info on this one: Not only has the output format
changed, but "print ${!array[$index]}" will print a value even if $index
is not an existing index of the array *and* even if the array, itself,
does not exist. It seems to have started in ksh-t:

_____________ ksh-s ______________
$ print ${.sh.version}
Version M 1993-12-28 s+
$ print ${!not_an_array[1]}

$
_____________ ksh-t ______________
$ print ${.sh.version}
Version M 93t 2008-11-04
$ print ${!not_an_array[1]}
not_an_array[1]
$
_____________ ksh-u ______________
$ print ${.sh.version}    
Version AJM 93u+ 2012-06-12
$ print ${!not_an_array[1]}
not_an_array[1]
$

    This change occurred to both indexed and associative arrays. I also
observed the following confusing behavior in ksh-t and ksh-u:

$ print ${!not_an_array[a]}
not_an_array[a]
$ array[a]=1
$ print ${!array[a]}      
array[0]
$ typeset -A assoc_array=([a]=1)
$ print ${!assoc_array[a]}     
assoc_array[a]
$

    What's more, tests now return true for a nonexistent array index, as
the following demonstrates:

_____________ ksh-s ______________
$ typeset -A assoc_array=([a]=1)
$ index=a                            
$ [[ ${!assoc_array[$index]} ]] && print "$index is an index of assoc_array"
a is an index of assoc_array
$ index=b
$ [[ ${!assoc_array[$index]} ]] && print "$index is an index of assoc_array"
$
_________ ksh-t & ksh-u __________
$ typeset -A assoc_array=([a]=1)                                           
$ index=a                                                                  
$ [[ ${!assoc_array[$index]} ]] && print "$index is an index of assoc_array"
a is an index of assoc_array
$ index=b                                                                  
$ [[ ${!assoc_array[$index]} ]] && print "$index is an index of assoc_array"
b is an index of assoc_array
$

So, scripts that were created before ksh-t and that use this specific
test for the existence of an array index now fail.

    It's really looking like a bug.

                    Terrence Doyle
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to