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.
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.
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/>.
14 # a start at a test suite for what it means for an array to be set or unset and
15 # how to test that state
21 if [ -v A ]; then echo assoc 1; else echo assoc 1 unset; fi
22 if [ -v a ]; then echo array 1; else echo array 1 unset; fi
24 if [ -v "${A[@]}" ]; then echo assoc 2; else echo assoc 2 unset; fi
25 if [ -v "${a[@]}" ]; then echo array 2; else echo array 2 unset; fi
42 if [ -v A[@] ]; then echo assoc A; else echo assoc A unset; fi
43 if [ -v a[@] ]; then echo array a; else echo array a unset; fi
45 if [ -v B[@] ]; then echo assoc B; else echo assoc B unset; fi
46 if [ -v b[@] ]; then echo array b; else echo array b unset; fi
48 if [ -v scalar1[@] ]; then echo scalar 1; else echo scalar 1 unset; fi
49 if [ -v scalar2[@] ]; then echo scalar 2; else echo scalar 2 unset; fi
50 if [ -v scalar3[@] ]; then echo scalar 3; else echo scalar 3 unset; fi
53 declare -A assoc=([one]=one [two]=two [three]=three)
54 declare -a array=(one two three)
56 scalar="one two three"
61 echo assoc: ${#assoc[@]}
62 echo array: ${#array[@]}
64 echo scalar: ${#scalar}
65 echo scalar: ${#scalar[@]}
67 echo scalar: ${#scalar2}
68 echo scalar: ${#scalar2[@]}
70 echo scalar: ${#scalar3}
71 echo scalar: ${#scalar3[@]}