typeset xx[7] is not a valid way to declare an array. IMO it might be
use full to throw an error in this case. David, what do you think?

Olga

On Mon, Mar 28, 2011 at 1:45 PM, Michal Hlavinka <[email protected]> wrote:
> Hi,
>
> one our user reported change in ksh's behavior. I've checked it and prepared 
> this simplified test case. Could you look at it? Thanks, Michal
>
> Simplified test case:
>
> typeset xx[7];
> echo ${#xx[@]};
> typeset -p xx;
> xx[6]=hello; echo ${xx[6]};
> typeset -p xx;
> xx[5]=world; echo ${xx[5]};
> typeset -p xx;
> xx[8]=foo; typeset -p xx;
> unset xx; typeset -p xx;
> echo ${#xx[@]}
>
> ksh >=2010-10-10 prints:
> 7 #why is that 7? bash,mksh, ksh<=2008-10-01 prints 0, ksh 2008-10-09 ... 
> 2010-09-24 prints 1
> typeset -a xx[7];xx=()
> <nothing> #should print hello
> typeset -a xx[7];xx=('' '' '' '' '' '' '') #definition unexpectedly changed 
> and 'hello' is missing
> <nothing> #should print world
> typeset -a xx[7];xx=('' '' '' '' '' '' '')
> xx[5]: subscript out of range #why out of range? why xx[5] , this was 
> xx[8]=foo assignment
> <nothing>
> 0
>
>
> ksh 2008-10-09 ... 2010-09-24 prints:
> 1
> typeset -a xx=([7]=)
> hello
> typeset -a xx=([6]=hello [7]=)
> world
> typeset -a xx=([5]=world [6]=hello [7]= [8]=foo)
> 0
>
>
> ksh <=2008-10-01 prints:
> 0
> typeset -a xx=([0]=)
> hello
> typeset -a xx=([6]=hello)
> world
> typeset -a xx=([5]=world [6]=hello [8]=foo)
> 0
>
>
> bash output for comparison:
> 0
> declare -a xx='()'
> hello
> declare -a xx='([6]="hello")'
> world
> declare -a xx='([5]="world" [6]="hello" [8]="foo")'
> bash: line 0: typeset: xx: not found
> 0
>
>
> _______________________________________________
> ast-developers mailing list
> [email protected]
> https://mailman.research.att.com/mailman/listinfo/ast-developers
>



-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     [email protected]   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to