| Line | |
|---|
| 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 |
|
|---|
| 16 | a+=5 printenv a
|
|---|
| 17 | echo $a
|
|---|
| 18 |
|
|---|
| 19 | # if the integer flag is set, ksh93 appears to do arithmetic += and evaluate
|
|---|
| 20 | # old value as an arithmetic expression
|
|---|
| 21 | a=
|
|---|
| 22 | typeset -i a
|
|---|
| 23 | a+=7
|
|---|
| 24 | echo $a
|
|---|
| 25 |
|
|---|
| 26 | b=4+1
|
|---|
| 27 | typeset -i b
|
|---|
| 28 | b+=37
|
|---|
| 29 |
|
|---|
| 30 | echo $b
|
|---|
| 31 |
|
|---|
| 32 | unset x
|
|---|
| 33 | x=(1 2 3 4 5)
|
|---|
| 34 |
|
|---|
| 35 | typeset -i x
|
|---|
| 36 |
|
|---|
| 37 | x[4]+=7
|
|---|
| 38 |
|
|---|
| 39 | echo ${x[@]}
|
|---|
| 40 |
|
|---|
| 41 | unset x
|
|---|
| 42 | typeset -i x
|
|---|
| 43 |
|
|---|
| 44 | x=([0]=7+11)
|
|---|
| 45 | echo ${x[@]}
|
|---|
| 46 |
|
|---|
| 47 | unset x
|
|---|
| 48 | x=(1 2 3 4 5)
|
|---|
| 49 |
|
|---|
| 50 | typeset -i x
|
|---|
| 51 |
|
|---|
| 52 | #x[4]=7+11
|
|---|
| 53 |
|
|---|
| 54 | x=(1 2 3 4 [4]=7+11 )
|
|---|
| 55 | echo ${x[@]}
|
|---|
| 56 |
|
|---|
| 57 | x=( 1 2 [2]+=7 4 5 )
|
|---|
| 58 | echo ${x[@]}
|
|---|
| 59 |
|
|---|
| 60 | x+=( [3]+=9 [5]=9 )
|
|---|
| 61 | echo ${x[@]}
|
|---|
| 62 |
|
|---|
| 63 | unset a
|
|---|
| 64 | a=1
|
|---|
| 65 | export a+=4
|
|---|
| 66 | printenv a
|
|---|
| 67 | printenv a+
|
|---|
| 68 |
|
|---|
| 69 | unset x
|
|---|
| 70 | typeset -i x=4+5
|
|---|
| 71 | echo $x
|
|---|
| 72 |
|
|---|
| 73 | unset x
|
|---|
| 74 | typeset x+=4
|
|---|
| 75 | echo $x
|
|---|
| 76 |
|
|---|
| 77 | typeset -i x+=5
|
|---|
| 78 | echo $x
|
|---|
| 79 |
|
|---|
| 80 | readonly x+=7
|
|---|
| 81 | echo $x
|
|---|
| 82 |
|
|---|
| 83 | x+=5
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.