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