OILS / spec / divergence.test.sh View on Github | oils.pub

117 lines, 57 significant
1## compare_shells: bash dash mksh zsh ash
2## oils_failures_allowed: 3
3
4# This file relates to:
5#
6# - doc/known-differences.md
7# - "divergence" tag on github:
8# https://github.com/oils-for-unix/oils/issues?q=is%3Aissue%20state%3Aopen%20label%3Adivergence
9
10#### xz package: dirprefix="${line##*([}"
11
12# https://oilshell.zulipchat.com/#narrow/channel/502349-osh/topic/alpine.20xz.20-.20.22.24.7Bline.23.23*.28.5B.7D.22.20interpreted.20as.20extended.20glob/with/519718284
13
14# NOTE: spec/extglob-match shows that bash respects it
15#
16# echo 'strip ##' ${x##@(foo)}
17
18shopt -s extglob
19
20
21dirprefix="${line##*([}"
22echo "-$dirprefix-"
23
24# Now try with real data
25line='*([foo'
26dirprefix="${line##*([}"
27echo "-$dirprefix-"
28
29## STDOUT:
30--
31-foo-
32## END
33
34## N-I mksh/zsh status: 1
35## N-I mksh/zsh STDOUT:
36## END
37
38#### !( as negation and subshell versus extended glob - #2463
39
40have_icu_uc=false
41have_icu_i18n=false
42
43if !($have_icu_uc && $have_icu_i18n); then
44 echo one
45fi
46echo two
47
48## STDOUT:
49one
50two
51## END
52
53## BUG mksh STDOUT:
54two
55## END
56
57#### Changing PATH will invalidate PATH cache
58
59mkdir -p _tmp/bin
60mkdir -p _tmp/bin2
61printf '#!/usr/bin/env sh\necho hi\n' >_tmp/bin/hello
62printf '#!/usr/bin/env sh\necho hey\n' >_tmp/bin2/hello
63chmod +x _tmp/bin/hello
64chmod +x _tmp/bin2/hello
65
66BIN=$PWD/_tmp/bin
67BIN2=$PWD/_tmp/bin2
68
69# Will find _tmp/bin/hello
70PATH="$BIN:$PATH" hello
71echo status=$?
72
73# Should invalidate cache and then find _tmp/bin2/hello
74PATH="$BIN2:$PATH" hello
75echo status=$?
76
77# Same when PATH= and export PATH=
78PATH="$BIN:$PATH"
79hello
80echo status=$?
81PATH="$BIN2:$PATH"
82hello
83echo status=$?
84
85export PATH="$BIN:$PATH"
86hello
87echo status=$?
88export PATH="$BIN2:$PATH"
89hello
90echo status=$?
91
92## STDOUT:
93hi
94status=0
95hey
96status=0
97hi
98status=0
99hey
100status=0
101hi
102status=0
103hey
104status=0
105## END
106
107#### builtin cat crashes a subshell (#2530)
108
109((/usr/bin/cat </dev/zero; echo $? >&7) | true) 7>&1
110
111((cat </dev/zero; echo $? >&7) | true) 7>&1
112
113## STDOUT:
114141
115141
116## END
117