mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-02-15 04:32:24 +00:00
Simple reproducer: set -A arr a b c d; : ${arr[1..2]}; unset arr[1]; echo ${arr[@]} Output: a Expected output: a c d The ${arr[1..2]} expansion broke the subsequent 'unset' command so that it unsets element 1 and on, instead of only 1. This regression was introduced in nv_endsubscript() on 2009-07-31: https://github.com/ksh93/ast-open-history/commit/c47896b4/src/cmd/ksh93/sh/array.c That change checks for the ARRAY_SCAN attribute which enables processing ranges of array elements instead of single array elements, and restores it after. That restore is evidently not correct as it causes the subsequent unset command to malfunction. If we revert that change, the bug disappears and the regression tests show no failures. However, I don't know what this was meant to accomplish and what other bug we might introduce by reverting this. However, no corresponding regression test was added along with the 2009-07-31 change, nor is there any corresponding message in the changelog. So this looks to be one of those mystery changes that we'll never know the reason for. Since we currently have proof that this change causes breakage and no evidence that it fixes anything, I'll go ahead and revert it (and add a regression test, of course). If that causes another regression, hopefully someone will find it at some point. src/cmd/ksh93/sh/array.c: nv_endsubscript(): - Revert the 2009-07-31 change that saves/restores the ARRAY_SCAN attribute. - Keep the 'ap' pointer as it is now used by newer code. Move the declaration up to the beginning of the block, as is customary. src/cmd/ksh93/sh/init.c: - Cosmetic change: remove an unused array_scan() macro that I found when grepping the code for ARRAY_SCAN. The macro was introduced in version 2001-06-01 but the code that used it was replaced in version 2001-07-04, without removing the macro itself. Resolves: https://github.com/ksh93/ksh/issues/254 |
||
---|---|---|
.. | ||
builtin | ||
INIT | ||
ksh93 | ||
Mamfile |