| Chet Ramey | 8868eda | 2020-12-06 15:51:17 -0500 | [diff] [blame] | 1 | # This program is free software: you can redistribute it and/or modify |
| 2 | # it under the terms of the GNU General Public License as published by |
| 3 | # the Free Software Foundation, either version 3 of the License, or |
| 4 | # (at your option) any later version. |
| 5 | # |
| 6 | # This program is distributed in the hope that it will be useful, |
| 7 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | # GNU General Public License for more details. |
| 10 | # |
| 11 | # You should have received a copy of the GNU General Public License |
| 12 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 13 | # |
| Chet Ramey | ac50fba | 2014-02-26 09:36:43 -0500 | [diff] [blame] | 14 | # start at a test suite for negative indexed array subscripts -- post bash-4.2 |
| 15 | x=( 0 1 2 3 4 5) |
| 16 | declare -p x |
| 17 | |
| 18 | unset 'x[-1]' |
| 19 | declare -p x |
| 20 | |
| 21 | unset 'x[-2]' |
| 22 | declare -p x |
| 23 | |
| 24 | unset 'x[-10]' |
| 25 | |
| 26 | x[-2]=3 |
| 27 | declare -p x |
| 28 | |
| 29 | x+=( five ) |
| 30 | declare -p x |
| 31 | x[-1]=5 |
| 32 | declare -p x |
| 33 | |
| 34 | x+=( [-1]=foo ) |
| 35 | declare -p x |
| 36 | |
| 37 | x[-1]=5 |
| 38 | declare -p x |
| 39 | |
| 40 | x[-2]+=four |
| 41 | declare -p x |
| 42 | |
| 43 | echo "strlen(${x[-2]})" = ${#x[-2]} |