]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/arith6.sub
Bash-5.2-rc4 release
[thirdparty/bash.git] / tests / arith6.sub
CommitLineData
8868edaf
CR
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#
ac50fbac
CR
14function reorder
15{
16 (( x[1] < x && (x=x[1], x[1]=$x) ))
17 echo "${x[@]}"
18}
19
20x=(123 456)
21reorder
22x=(456 123)
23reorder
24
25unset x
26unset -f reorder
27
28function reorder
29{
30 (( x[1] < x[0] && (x=x[1], x[1]=$x) ))
31 echo "${x[@]}"
32}
33
34x=(123 456)
35reorder
36x=(456 123)
37reorder
38
39unset x
40unset -f reorder
41
42function reorder
43{
44 (( x[1] < x[0] && (x[0]=x[1], x[1]=$x) ))
45 echo "${x[@]}"
46}
47
48x=(123 456)
49reorder
50x=(456 123)
51reorder
52
53unset -f reorder
54
55n=0 ; (( (a[n]=++n)<7&&a[0])); echo "${a[@]:1}"
56
57n=0 a="(a[n]=++n)<7&&a[0]"; ((a[0])); echo "${a[@]:1}"
58
59n=0 a="(a[n]=n++)<7&&a"; ((a)); echo "${a[@]:1}"
60
61# bugs with lvalue caching and pointer aliasing through bash-4.2
62echo $(( a=(y[0] + y[1]) & 0xff, b=(y[2] + y[3]) & 0xff, a << 8 | b))
63echo $a, $b
64((a = y[0], b = 1 ))
65echo $a, $b