OILS / spec / paren-ambiguity.test.sh View on Github | oils.pub

149 lines, 59 significant
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
7echo 2
8(( x ))
9: $(( x ))
10echo 3
11) )
12
13## STDOUT:
141
152
163
17## END
18
19#### $(( closed with ) ) after multiple lines is command - #2337
20
21echo $(( echo 1
22echo 2
23(( x ))
24: $(( x ))
25echo 3
26) )
27
28## STDOUT:
291 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
40echo 2
41(( x ))
42: $(( x ))
43echo 3
44))
45'
46if test $? -ne 0; then
47 echo ok
48fi
49
50## STDOUT:
51ok
52## END
53## OK dash/ash STDOUT:
541
552
563
57## END
58
59#### $(( closed with )) after multiple lines is parse error - #2337
60
61$SH -c '
62echo $(( echo 1
63echo 2
64(( x ))
65: $(( x ))
66echo 3
67))
68'
69if test $? -ne 0; then
70 echo ok
71fi
72
73## STDOUT:
74ok
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
82good() {
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
86bad() {
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
91good
92bad
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
101gzip_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)
108echo bye
109
110## STDOUT:
111bye
112## END
113
114#### ((pkg-config example - postfix package - #2337
115
116icu_cppflags=`((pkg-config --cflags icu-uc icu-i18n) ||
117 (pkgconf --cflags icu-uc icu-i18n) ||
118 (icu-config --cppflags)) 2>/dev/null`
119echo bye
120
121## STDOUT:
122bye
123## END
124
125#### ((test example - liblo package - #2337
126
127if ! ((test x"$i" = x-g) || (test x"$i" = x-O2)); then
128 CF="$CF $i"
129fi
130echo bye
131
132## STDOUT:
133bye
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 ||
139echo /opt/gnome/bin/gtk-update-icon-cache)2>/dev/null)"
140
141echo bye
142
143## STDOUT:
144bye
145## END
146
147## N-I dash/ash status: 2
148## N-I dash/ash STDOUT:
149## END