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