1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix the output of typeset -p for two dimensional indexed arrays (#454)

In ksh93v- 2012-10-04 the following bugfix is noted in the changelog
(this fix was most likely part of ksh93v- 2012-09-27, although that
version is not archived anywhere):
12-09-21  A bug in which the output of a two dimensional sparse
          indexed array would cause the second subscript be treated
          as an associative array when read back in has been fixed.
          Elements that are sparse indexed arrays now are prefixed
          type "typeset -a".

Below is a before and after of this change:

   # Before
   $ typeset -a foo[1][2]=bar
   $ typeset -p foo
   typeset -a foo=([1]=([2]=bar) )

   # After
   $ typeset -a foo[1][2]=bar
   $ typeset -p foo
   typeset -a foo=(typeset -a [1]=([2]=bar) )

src/cmd/ksh93/sh/*.c:
- Backport changes from ksh93v- to print 'typeset -a' before sparse
  indexed arrays and properly handle 'typeset -a' in reinput
  commands from 'typeset -p'.

src/cmd/ksh93/tests:
- Add two regression tests to arrays.sh for this change.
- Update the existing regression tests for compatibility with the
  new printed typeset output.
This commit is contained in:
Johnothan King 2022-02-08 11:40:17 -08:00 committed by Martijn Dekker
parent e6d0187dd8
commit 787058bdbf
13 changed files with 80 additions and 16 deletions

View file

@ -90,6 +90,7 @@ typedef struct _shlex_
char noreserv; /* reserved works not legal */
int inlineno; /* saved value of sh.inlineno */
int firstline; /* saved value of sh.st.firstline */
int assignlevel; /* nesting level for assignment */
#if SHOPT_KIA
Sfio_t *kiafile; /* kia output file */
Sfio_t *kiatmp; /* kia reference file */