OILS / spec / nocasematch-match.test.sh View on Github | oilshell.org

71 lines, 43 significant
1## compare_shells: bash
2## oils_failures_allowed: 0
3
4# Tests nocasematch matching
5
6#### [[ equality matching
7shopt -s nocasematch
8[[ a == A ]]; echo $?
9[[ A == a ]]; echo $?
10[[ A == [a] ]]; echo $?
11[[ a == [A] ]]; echo $?
12## STDOUT:
130
140
150
160
17## END
18
19#### [[ regex matching
20shopt -s nocasematch
21[[ a =~ A ]]; echo $?
22[[ A =~ a ]]; echo $?
23[[ a =~ [A] ]]; echo $?
24[[ A =~ [a] ]]; echo $?
25## STDOUT:
260
270
280
290
30## END
31
32#### [ matching
33shopt -s nocasematch
34[ a = A ]; echo $?
35[ A = a ]; echo $?
36## STDOUT:
371
381
39## END
40
41#### case matching
42shopt -s nocasematch
43case a in A) echo 0 ;; *) echo 1 ;; esac
44case A in a) echo 0 ;; *) echo 1 ;; esac
45case a in [A]) echo 0 ;; *) echo 1 ;; esac
46case A in [a]) echo 0 ;; *) echo 1 ;; esac
47## STDOUT:
480
490
500
510
52## END
53
54#### file matching
55shopt -s nocasematch
56touch a B
57echo [A] [b]
58## STDOUT:
59[A] [b]
60## END
61
62#### parameter expansion matching
63shopt -s nocasematch
64foo=a
65bar=A
66echo "${foo#A}" "${foo#[A]}"
67echo "${bar#a}" "${bar#[a]}"
68## STDOUT:
69a a
70A A
71## END