mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix creation of extra associative array element '0' (#101)
Multidimensional associative arrays are created with an extra array member named '0', which is set to no value. Reproducer: $ typeset -A foo $ typeset -A foo[bar] $ typeset -p foo typeset -A foo=([bar]=([0]='') ) The bugfix prevents nv_setarray from creating the extra '[0]' member when an associative array is empty. This bug was discussed on the old mailing list: https://www.mail-archive.com/ast-developers@lists.research.att.com/msg01574.html src/cmd/ksh93/sh/array.c: - Do not allow the creation of an extra array member when an array is empty. src/cmd/ksh93/tests/arrays.sh: - Add a regression test for creating multidimensional associative arrays, but use the output from 'typeset -p' instead of fgrep.
This commit is contained in:
parent
70f6d758c0
commit
02a14ff9b7
4 changed files with 17 additions and 2 deletions
|
@ -1003,7 +1003,7 @@ Namarr_t *nv_setarray(Namval_t *np, void *(*fun)(Namval_t*,const char*,int))
|
|||
ap->nelem = nelem;
|
||||
ap->fun = fun;
|
||||
nv_onattr(np,NV_ARRAY);
|
||||
if(fp || value)
|
||||
if(fp || (value && value!=Empty))
|
||||
{
|
||||
nv_putsub(np, "0", ARRAY_ADD);
|
||||
if(value)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue