]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/appendop.tests
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / appendop.tests
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 #
14 # basic cases
15 a=1
16 a+=4
17 echo $a
18
19 x=(1 2 3)
20 x+=(4 5 6)
21
22 echo ${x[@]}
23
24 x[4]+=1
25 echo ${x[@]}
26
27 # trickier cases
28 # post-bash-4.2: bash understands += in environment assignments preceding
29 # command names
30 a+=5 printenv a
31 echo $a
32
33 # if the integer flag is set, ksh93 appears to do arithmetic += and evaluate
34 # old value as an arithmetic expression
35 a=
36 typeset -i a
37 a+=7
38 echo $a
39
40 b=4+1
41 typeset -i b
42 b+=37
43
44 echo $b
45
46 unset x
47 x=(1 2 3 4 5)
48
49 typeset -i x
50
51 x[4]+=7
52
53 echo ${x[@]}
54
55 unset x
56 typeset -i x
57
58 x=([0]=7+11)
59 echo ${x[@]}
60
61 unset x
62 x=(1 2 3 4 5)
63
64 typeset -i x
65
66 #x[4]=7+11
67
68 x=(1 2 3 4 [4]=7+11 )
69 echo ${x[@]}
70
71 x=( 1 2 [2]+=7 4 5 )
72 echo ${x[@]}
73
74 x+=( [3]+=9 [5]=9 )
75 echo ${x[@]}
76
77 unset a
78 a=1
79 export a+=4
80 printenv a
81 printenv a+
82
83 unset x
84 typeset -i x=4+5
85 echo $x
86
87 unset x
88 typeset x+=4
89 echo $x
90
91 typeset -i x+=5
92 echo $x
93
94 readonly x+=7
95 echo $x
96
97 x+=5
98
99 ${THIS_SH} ./appendop1.sub
100 ${THIS_SH} ./appendop2.sub