1 ## compare_shells: bash dash mksh zsh ash
2 ## oils_failures_allowed: 3
3
4 #### (( closed with ) ) after multiple lines is command - #2337
5
6 (( echo 1
7 echo 2
8 (( x ))
9 : $(( x ))
10 echo 3
11 ) )
12
13 ## STDOUT:
14 1
15 2
16 3
17 ## END
18
19 #### $(( closed with ) ) after multiple lines is command - #2337
20
21 echo $(( echo 1
22 echo 2
23 (( x ))
24 : $(( x ))
25 echo 3
26 ) )
27
28 ## STDOUT:
29 1 2 3
30 ## END
31
32 ## BUG dash/ash status: 2
33 ## BUG dash/ash STDOUT:
34 ## END
35
36 #### (( closed with )) after multiple lines is parse error - #2337
37
38 $SH -c '
39 (( echo 1
40 echo 2
41 (( x ))
42 : $(( x ))
43 echo 3
44 ))
45 '
46 if test $? -ne 0; then
47 echo ok
48 fi
49
50 ## STDOUT:
51 ok
52 ## END
53 ## OK dash/ash STDOUT:
54 1
55 2
56 3
57 ## END
58
59 #### $(( closed with )) after multiple lines is parse error - #2337
60
61 $SH -c '
62 echo $(( echo 1
63 echo 2
64 (( x ))
65 : $(( x ))
66 echo 3
67 ))
68 '
69 if test $? -ne 0; then
70 echo ok
71 fi
72
73 ## STDOUT:
74 ok
75 ## END
76
77 #### (((grep example - 4+ instances in regtest/aports - #2337
78
79 # https://oilshell.zulipchat.com/#narrow/channel/502349-osh/topic/.28.28.28.20not.20parsed.20like.20bash/with/518874141
80
81 # spaces help
82 good() {
83 cputype=`( ( (grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null`
84 }
85
86 bad() {
87 cputype=`(((grep cpu /proc/cpuinfo | cut -d: -f2) ; ($PRTDIAG -v |grep -i sparc) ; grep -i cpu /var/run/dmesg.boot ) | head -n 1) 2> /dev/null`
88 #echo cputype=$cputype
89 }
90
91 good
92 bad
93
94 ## STDOUT:
95 ## END
96
97 #### ((gzip example - zdiff package - #2337
98
99 # https://github.com/git-for-windows/git-sdk-64/blob/main/usr/bin/zdiff#L136
100
101 gzip_status=$(
102 exec 4>&1
103 (gzip -cdfq -- "$file1" 4>&-; echo $? >&4) 3>&- |
104 ((gzip -cdfq -- "$file2" 4>&-
105 echo $? >&4) 3>&- 5<&- </dev/null |
106 eval "$cmp" /dev/fd/5 - >&3) 5<&0
107 )
108 echo bye
109
110 ## STDOUT:
111 bye
112 ## END
113
114 #### ((pkg-config example - postfix package - #2337
115
116 icu_cppflags=`((pkg-config --cflags icu-uc icu-i18n) ||
117 (pkgconf --cflags icu-uc icu-i18n) ||
118 (icu-config --cppflags)) 2>/dev/null`
119 echo bye
120
121 ## STDOUT:
122 bye
123 ## END
124
125 #### ((test example - liblo package - #2337
126
127 if ! ((test x"$i" = x-g) || (test x"$i" = x-O2)); then
128 CF="$CF $i"
129 fi
130 echo bye
131
132 ## STDOUT:
133 bye
134 ## END
135
136 #### $((which example - command sub versus arith sub - gnunet-gtk package
137
138 gtk_update_icon_cache_bin="$((which gtk-update-icon-cache ||
139 echo /opt/gnome/bin/gtk-update-icon-cache)2>/dev/null)"
140
141 echo bye
142
143 ## STDOUT:
144 bye
145 ## END
146
147 ## N-I dash/ash status: 2
148 ## N-I dash/ash STDOUT:
149 ## END