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

Fix spurious syntax error when using ${foo[${bar}..${baz}]} (#436)

Attempting to use array subscript expansion with variables that
aren't set currently causes a spurious syntax error (in ksh93u+ and
older commits the reproducer crashes):
   $ ksh -c 'echo ${foo[${bar}..${baz}]}'  # Shouldn't print anything
   ksh: : arithmetic syntax error

src/cmd/ksh93/sh/macro.c:
- Backport a parser bugfix from ksh93v- 2012-08-24 that avoids
  setting mp->dotdot until the copyto() function's loop is
  finished.

src/cmd/ksh93/tests/arrays.sh:
- Add regression tests for this bug.
This commit is contained in:
Johnothan King 2022-01-27 04:55:36 -08:00 committed by Martijn Dekker
parent fe268fcc91
commit c0567c5e1d
3 changed files with 21 additions and 1 deletions

3
NEWS
View file

@ -8,6 +8,9 @@ Any uppercase BUG_* names are modernish shell bug IDs.
- On Cygwin, ksh now executes scripts that do not have a #! path itself,
like it does on other systems, instead of with /bin/sh.
- Fixed a spurious syntax error which occurred when attempting to use array
subscript expansion with unset variables (i.e., ${foo[${bar}..${baz}]}).
2022-01-24:
- Fixed a crashing bug in history expansion that could occur when using the "&"